Jump to content
Search Community

Update Dynamic Text in Timeline Tween Sequences

Vince test
Moderator Tag

Recommended Posts

Hi All,

 

I am looking for some advice and guidance please.

 

I currently have a Timeline with various tweens appended within this timeline (Sequence).

 

I then have a dynamic text box which I want the content to update with text I have populated in an array.

 

I am currently using onUpdate to update my text boxes, however only the last update is ever shown at run time in my text box, as I assume its already jumped through all the previous tweens at the same time, even though I have various other tweens appended before and after. I assume I am not using the   onUpdate function correctly? How can I get my text boxes to update one after the other (sequence) like previous tweens I have appended to the timeline.

 

Example part of my code:

 

 

function setSteptext(stepNumbercount:int):void
{
stepNumber.stepNumberfield.text = String(stepNumbercount);
stepText.stepTextfield.text = descripArray[stepNumbercount];
trace(stepNumber.stepNumberfield.text);
}


var myTimeline:TimelineMax = new TimelineMax();


myTimeline.append(TweenMax.to(this, fadeSpeed, {onUpdate:setSteptext(1)}));
myTimeline.append(TweenMax.to(this, fadeSpeed, {onUpdate:setSteptext(2)}));
myTimeline.append(TweenMax.to(this, fadeSpeed, {onUpdate:setSteptext(3)}));
myTimeline.append(TweenMax.to(this, fadeSpeed, {onUpdate:setSteptext(4)}));
 
There are other Tweens appended inbetween these text updates (have removed them for simplicity), these play one after the other fine, as I'd expect however the text tweens which use onUpdate seem to run straight through without waiting for any other tweens.
 
Thanks in advance
 
Vince
 
 
 
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

It appears you just need to modify your code a bit to pass paramaters to the onUpdate function.

 

Also, keep in mind that onUpdate fires at the frame rate of the swf. If your swf has a framerate of 30, and fadeSpeed = 1, you will call onUpdate 30 times throughout the course of the tween.

 

I think you would do fine using onStart or onComplete, either way you need to use onUpdateParams, onStartParams or onCompleteParams (depending on which option you choose).

 

When ever you have a function call like this 

 

setSteptext(1) in your code, even if its part of a tween property value, that function will get called immediately as soon as that line of code is executed... it won't wait for the tween to run.

 

Do this

myTimeline.append(TweenMax.to(this, fadeSpeed, {onUpdate:setSteptext, onUpdateParams:[1]}))

onUpdateParams takes and array [ ] as your function may need to accept multiple parameters. Check the TimelineLite docs for more info.

 

Also, if you are using v12 of the platform (recommended), you can condense your code quite a bit to:

myTimeline.to(this, fadeSpeed, {onUpdate:setSteptext, onUpdateParams:[1]})
  .to(this, fadeSpeed, {onUpdate:setSteptext, onUpdateParams:[2]})
  .to(this, fadeSpeed, {onUpdate:setSteptext, onUpdateParams:[3]})
  .to(this, fadeSpeed, {onUpdate:setSteptext, onUpdateParams:[4]})

v12 docs for TimelineLite.to()

 

Again, test to see if onStart and onStartParams does the trick too.

 

get v12 http://www.greensock.com/?download=GSAP-AS3

 

learn about v12:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...