Jump to content
Search Community

Help with addLabel in TimeLineMax

MerrickBrewer test
Moderator Tag

Recommended Posts

Could someone lend me some knowledge?!!

 

Is it possible to take this addLabel string:

 

 

overviewtl.addLabel("Sequence 01", overviewtl.duration);

 

and have it update a dynamic text box on the stage. It's for client editing purposes, so they can have a reference to the sequence name within a long timelineMax build. My knowledge of AS3 really lets me down sometimes, but I usually manage from Carl's tutorials and the forums here to get what I need to work. This case, I'm stumped! I've already built in the progress bar and slider + play pause functions which all work a treat - this final bit would be the icing on the cake!

 

Thanks in advance,

 

Merrick

Link to comment
Share on other sites

Stand down. Finally worked it out!

 

Labelled my sequences with the addLabel, then on the first timeline instance of each sequence, did a OnStart - then in that function told the text to be:

 

sequence_txt.text= int(overviewtl.currentLabel);

 

called the function again when you use the scrubber at the bottom and it updates the sequence number as you slide it. Perfect.

 

God I love Greensock!!!

Link to comment
Share on other sites

Howdy Merrick.

 

Thanks for dropping in. Sorry I couldn't get to this sooner.

 

What you are doing is totally fine.

The only issue is that the onStart callback won't fire if the client is scrubbing in reverse. May not be a big deal. Here are some more options:

 

in v11

TimelineMax has an addCallback() method that will allow you to place function calls anywhere on a timeline instead of placing them in the onStart of a tween in the timeline. addCallback will fire regardless of which direction the timeline is playing or being scrubbed

 

tl.addLabel("tween3");
tl.append(TweenLite.to( ... ));
tl.addCallback(showText, "tween3");

 

v12

 

TimelineLite and TimelineMax:

Use append() which will append a tween, timeline, label or callback to the end of the timeline

tl.append("tween3"); //add label
tl.append(showText); //add callback
tl.append(TweenLite.to( ... )); //add tween

//or with method chaining

tl.append("tween3").append(showText).append(TweenLite.to( ... ))

 

 

TimelineMax has addCallback just like v11 (note addCallback is only necessary if you want to pass parameters to your function like so

 

tl.addCallback(showText, tl.duration, [name:'carl', favoriteColor:'green']);

 

The neatest option in v12 is to use insert()

 

tl.insert(showText, "section3");  //adds callback and label to end of timeline
tl.append(TweenLite.to(mc, 1, {x:100}));

 

The interesting thing about that code is this. If the section3 label exists, that is exactly where the callback will be added.

 

If the section3 label does not exist, one will be added to the end of the timeline and that is where the callback will go. So in a way, insert() can be used to "append a label to the end and add my tween, label, timeline or callback there".

 

And you can super-condense it with v12's convenience methods and chaining like so:

 

tl.insert(showText, "section3)
 .to(mc, 1, {x:100})

 

 

that little snippet above will create a label called "section3" at the end of the timeline and also add the showText callback with a TweenLite.to tween at the exact same point in time.

 

super!

 

---

 

Take it easy man,

 

Carl

  • Like 1
Link to comment
Share on other sites

Hi Carl,

 

Thanking you in heaps for this. Awesome to see a staff badge on your icon as well. Congrats for this. And for this explanation as well. Clearly demonstrates the love and respect that Greensock absolutely deserves with this forum. I realised when I posted that the time over your way was 7.45am, it was already late afternoon and had spent most of the morning trying to snip away at the addLabel issue!

 

Anyway, I stuck in the function to update the text on the scrubbers drag function so that it fired the onStart method when the user lets go. It's pretty crude compared to your super in depth explanation! I hadn't looked into or read anything about the callBack method. This is fantastic stuff!!

 

If I'm reading this right, I can essentially insert/append a function into my timeline? Niiiiiice. I see some used for this already in my flash adventures!

 

Thanks again Carl, outstanding work yet again. From over in the English Isles, I tip my hat to you sir!

  • Like 1
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...