Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : Tweening Dynamic Text


phej
6/13/2005 10:09:41 PM
I have spent the past hour searching the forums for an answer to this and
haven't found one, so I'm posting it. If there is an answer that I missed, I
apologize!

I am trying to figure out how to tween a dynamic text field. My developer has
written a part of the website I'm working on to output a text file and they
want me to import the text file (which I can do) and have it scroll (bottom to
top) through the contents (names, etc).

I know you can't tween the field, you have to put it in an MC (which I've
named 'winners') and tween the MC, but I can't get it to work.

Here's the code I'm using:

myData = new LoadVars();
myData.onLoad = function() {

myHeadline_txt.htmlText = this.headline;
myText_txt.htmlText = this.content;
};

myData.load("/flash/text.txt");

stop();

--

Any help or advice I can get would be wonderful!
sneakyimp
6/13/2005 11:36:36 PM
if you have the the text showing up properly, that's half the battle.

in order to have the text scroll, i would recommend creating a periodic
function which moves the text Up. make sure that when your text gets loaded
that the two text fields are below the bottom of your screen. this can be done
in your onLoad() function. if you changed your onload function to also move
the playback of your main movie to frame 2, you could put something like this
in frame 2

this.onEnterFrame = function() {
myHeadline_text._y -= 20;
myText_text._y -= 20;
}

the other possiblity is that your onLoad() function, instead of going to
frame2, could create an interval function similar to that onEnterFrame function
which moves the text objects. with setInterval, though, you have to be careful
to properly delete interval functions or they will stack up, causing your text
to scroll very fast.


sneakyimp
6/13/2005 11:37:59 PM
oh...the other thing you'll need to do is in your periodic text-moving
function, you'll need to check to see if your text has scrolled off the
top...in which case you move it down again.

for that, you'll need to check the size of your text fields...otherwise, it
will be impossible to determine when they have actually scrolled off the top.


phej
6/14/2005 12:27:32 PM
Unfortunately, I do not have the text showing up yet. I've been googling for
the past couple of days trying to come up with an answer as my work really
doesn't delve much into the heavy actionscript, thus I don't know a lot of it.

What should I try next?
AddThis Social Bookmark Button