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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another scrolling text question 1

Status
Not open for further replies.

Sardamil

Programmer
Apr 14, 2001
77
NL
I know that many people have asked about scrolling text before, but I still need your help.

Here's my problem. I want to have a single line of text scrolling from the right to the left side of the movie. I also want it to be continuous and seemless. So far I did manage the scrolling of the text by using tween, but I have to wait for the full line of text to be finished before it starts again. I would like to see the end of the text immediately followed by the beginning.

This must be an easy one for you experienced people, but would you please help this newbie solve this puzzle.

I need to say that I want to export the movie to an animated gif. I don't know if that is important or not.
 
Here's how to do it for standard Flash movie...


...and this is the script that makes it run. You put this on a dummy or control clip on the stage. You also need a clip called "text" which contains a dynamic textbox with variable "letter" to make this work:

onClipEvent (load) {
myString = "This is a long line of scrolling text that loops around, over and over and over.";
space=10;right = myString.length*space;
left = 0;
speed = 3;
;
for (i=1; i<=myString.length; i++) {
duplicateMovieClip (_root.text, &quot;text&quot;+i, i);
clip = _root[&quot;text&quot;+i];
clip.letter = myString.charAt(i-1);
clip._x = i*space;
clip._y = 200;
}
}
onClipEvent (enterFrame) {
for (i=1; i<=myString.length; i++) {
clip = _root[&quot;text&quot;+i];
clip._x -= speed;
if (clip._x<left) {
clip._x = right;
}
}
}


I've not used the animated .gif export feature so I don't know if it renders things which are script driven (I expect it doesn't) so this example is a)just in case it does and b) here for anybody else that might have a use for it.

I think your best option is to build the animation as a frame by frame (i.e. not tweened) animation - if you carefully plan out the point where the loop restarts you should be able to create a smooth loop effect.

Otherwise there are a couple of third party software applications that create these kind of text effects for you without you having to do any programming or animation but I've never used any so don't know what to recommend - Oldnewbie is your man for that kind of information.
 
wang this works good for a jukebox i'm building but theres only one problem..the text is not showing up in the mc text, which contains a dynamic text box with variable &quot;letter&quot;..the text scrolls but it locks to the middle of the movies main time line and does not show up in the mc text location?..

any ideas?.
logo.gif


carlsatterwhite@orlandomediasolutions.com
 
ok i kinda worked it out but i need your help with this..i figured out by changing the value of

clip._x = i*space;
clip._y = 200;

will move the text around the stage right?..


info on mc _root.text in my movie:

W:439.4 X:245.7
H:23.0 Y:107.4

how do i plug that into your script to get the scroll inside _root.text..........

i will use it for the name of the band that is playing at the time to be scrolling across the screen...




logo.gif


carlsatterwhite@orlandomediasolutions.com
 
Hey Virt, not sure that I'm following you on this one so here's a detailed breakdown of how it works. Hope it helps...

onClipEvent (load) {

insert your band name here
myString = &quot;This is a long line of scrolling text... &quot;;

this calculates how long the text is in pixels
space=10;
right = myString.length*space;
left = 0;
speed = 3;

for (i=1; i<=myString.length; i++) {

create a separate clip for each letter of the string
duplicateMovieClip (_root.text, &quot;text&quot;+i, i);
clip = _root[&quot;text&quot;+i];

chop out a single letter from the string and set the duplicate text box variable equal to it
clip.letter = myString.charAt(i-1);

place the text box on the stage at the correct location
clip._x = i*space;
clip._y = 200;
}
}
onClipEvent (enterFrame) {
for (i=1; i<=myString.length; i++) {
clip = _root[&quot;text&quot;+i];

move the letters
clip._x -= speed;

check to see if the letter has left the stage - if so wrap it around so it reappears
if (clip._x<left) {
clip._x = right;
}
}
}

I'll send you the .fla as well.

 
Wangbar,

thanx for the help, but could you send me the fla as well.

Sardamil
sardamil@yahoo.co.uk
 
Okay, had a think and came up with a much better solution...

This is more of a string-based thing than a duplicate movieClip deal which makes it more useful for you Virt: the positioning problem goes away with this version as you can see exactly where you're placing the text, plus you can limit the amount of characters you display at any one time with a variable rather than rely on masks to chop things down to size (which wouldn't work in your jukebox movie anyway without some serious swapDepths stuff which began to get really complicated - I know, I tried :) )

Here's the script - stick it in a dummy clip as before but this time have a simple textbox on the stage with variable name &quot;display&quot; to show your scrolling text. What you lose in smoothness in the scroll you get back in flexibility: mess around with &quot;displayLength&quot; to get what you need sizewise and you can drop the textbox exactly where you want it to show with no guessing.


onClipEvent (load) {
myString = &quot;Insert the name of the band here &quot;;
displayLength = 12;
}
onClipEvent (enterFrame) {
display = &quot;&quot;;
for (i=0; i<displayLength; i++) {
if (place>=myString.length) {
place = 0;
}
pointer = place+i;
if (pointer>=myString.length) {
pointer-=myString.length;
}
display += myString.charAt(pointer);
}
place++;
_root.display = display;
}


By the way - the trailing space in myString is important...
 
By the way - the trailing space in myString is important...

huh?

and thanks bro..give ya another star but i can't..already did..
logo.gif


carlsatterwhite@orlandomediasolutions.com
 
I just meant that whatever you type in as &quot;myString&quot; leave an extra blank space character at the end or else your loop will be all jammeduplikethis ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top