Jump to content
Search Community

Listening for labels in Timelines?

cerulean test
Moderator Tag

Recommended Posts

If one has has a long timeline with various 'sections', which one could delineate by labels, what is the best way to know when it has played through a section?

 

Is there a way to 'listen' for a tlmeline passing through labels — or is the best way to add a callback at the end of each section which would dispatch an Event?

PSEUDO CODE

_timeline.addLabel('start section 1',_timeline.totalDuration());
_timeline.to(...);
_timeline.addLabel('end section 1',_timeline.totalDuration()); // can I detect when this passes?
_timeline.addCallBack(dispatchAnEvent(finishedSection1),_timeline.totalDuration());  // or is this the only way?

Thanks for any help.

  • Like 1
Link to comment
Share on other sites

Yes, adding a callback would be the best route.

 

I know that was pseudo code but here is another way of adding a label at the current end of the timeline

 

better

_timeline.add("myLabel");

 

 

ok, but not necessary

_timeline.addLabel('start section 1',_timeline.totalDuration());

 

 

also keep in mind that TimelineMax has more label-related methods than TimelineLite such as

 

currentLabel();

getLabelAfter();

getLabelBefore();

getLabelsArray();

 

http://api.greensock.com/as/com/greensock/TimelineMax.html

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...