Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Text Scroll in a text field? 1

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
US
how would I go about making a certain size text box and then having the text scroll if it is longer than the size of the text box?
 
Set your dynamic textbox to "Multiline" and give it a variable name. Then set the scroll property of the variable to move the text.

If your textbox variable was named "scrollBox" and you wanted to scroll it using an up and a down button you'd just need to do the following.

Up Button

on(release){
scrollBox.scroll+=1;
}


Down Button

on(release){
scrollBox.scroll-=1;
}
 
HOw do you set the scroll property of the variable for the text box? I am missing a step here :)

Thanks
 
No you're not :)

The scroll property is actually set by the line

scrollBox.scroll+=1;

that's it, it's just there - no tricks, just like setting a property on a movieclip.
 
okay guys,

I'm trying to scoll a text box similar to this, but have the textbox scroll automaticly with aon on load statement.


Here's the problem,

because the movie is set at 12 frame per second it scrolls to fast.

I need to the movie set 12/sec.

any idea on how to slow the scroll down and so the suer can read it, with out changing the frame rate.

thanks
Jef

 
How about using getTimer() to delay incrementing the scroll amount?

This sets up a loop which gets the current time as the movieclip loads then increments the scroll property after a second or so until the whole textbox has scrolled - set the variable maxlines to the amount of lines of text you want to scroll and substitute your dynamic text variable for textBox (hey, it's late here - can't come up with imaginative variable names ;-) )...

onClipEvent (load) {
for (i=1; i<maxLines; i++) {
startTime = getTimer();
do {
elapsedTime = getTimer();
} while (elapsedTime-startTime<1000);
textBox.scroll += 1;
}
}


The only problem with doing things this way is that everything else comes to a standstill while the script runs.



 
unless you plan on updating the text file through the server the only way around that problem would be to fix the text in a scrolling tween inside a movie clip.. maybe?..wangbars explanation is great but if what he says is true about the script stoping the rest of the movie while it runs would probably not be a good thing..
e.gif


carlsatterwhite@endangeredgraphics.com
 
You could use onClipEvent(enterFrame) to increment a variable every frame and use this as a counter to step through the scroll...

onClipEvent (enterFrame) {
counter += 1;
//only scroll every 5 frames
increment = counter%5;
if (increment=0) {
textBox.scroll += 1;
// or-=1 depending on direction
}
}



 
this is just what I did, but the text ends up being very &quot;jerky&quot; very hard to read.

and yes the paln was to bring the text into the text feild from the server so any writer could update it easily.

what do you guys think about a movieclip that tweens the text under a mask, there would be no way to know how long the text was so you could make it stop at a defined point but ti might scroll smoothly.

let me know

what you think

jef
 
Smoothing the motion of the text out might be as simple as adding...

updateAfterEvent();

to your clipEvent, this instantly refreshes the screen and definitely makes a big difference when you're moving graphics around, should do the same for the text.

If not there's no reason you couldn't move the whole textbox around under a mask but if you're tweening you'll have to embed the fonts in order for them to display. It's probably easier to use a piece of script to move the box pixel at a time rather than tween in this case.
 
here is the code

am I using the updateAfterEvent statement correctly?


onClipEvent (load) {
scrolling = 1;
frameCounter = 0;
speedFactor = 3;

updateAfterEvent(enterframe);

}

onClipEvent (load) {
scrolling = &quot;down&quot;;
frameCounter = speedFactor
if ( frameCounter%speedFactor == 1 ) {
if (scrolling == &quot;up&quot; && who_text.scroll>1) {
who_text.scroll--;
} else if (scrolling == &quot;down&quot; && who_text.scroll<who_text.maxscroll) {
who_text.scroll++;
}
frameCounter = 1;
}
frameCounter++;

updateAfterEvent(enterframe);

}

onClipEvent (enterFrame) {
if (frameCounter%speedFactor == 0) {
if (scrolling == &quot;up&quot; && who_text.scroll>1) {
who_text.scroll--;
} else if (scrolling == &quot;down&quot; && who_text.scroll<who_text.maxscroll) {
who_text.scroll++;
}
frameCounter = 0;
}
frameCounter++;

updateAfterEvent(enterframe);

}



if so, doesn't seem to help


maybe this is one that just can't be done.


a friend pointed me to a java applet taht does this very nice, but I don't think we can embed javaapplets in Flash (smile)

anit life grand

let me know
 
I believe updateAfterEvent() doesn't take enterFrame as an argument (although if it doesn't throw an error, what the heck...;-) ). So it might be that in some of your script it only works when the clip loads i.e. once only. To really see the benefits of the action it has to be used in an enterFrame or mouseMove situation.

I don't know if you just cut and pasted this from your movie but if you did then you have &quot;enterframe&quot; in brackets rather than &quot;enterFrame&quot; which will make a difference in it is allowed as an argument. Whenever I've used it in the past I just add it to the clipEvent with no arguments in the brackets and it works great.

When I get a moment I'll run your script and see if I can help out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top