Jump to content
Search Community

TimelineMax callback checking

mindspaced test
Moderator Tag

Recommended Posts

Morning!

 

I've created a simple timeline scrubber that uses the gotoAndPlay method of timelineMax. Works beautifully, thanks to Jack's hard work on the platform.

 

However, I also use the addCallback method to trigger other actions on the timeline. An example for one animation is that I want to trigger an flv to start playing at 20 seconds. So I add tl.addCallback(playFlv, 20); Easy enough.

 

However, I'm trying to figure out how to handle the event that someone scrubs 21 seconds into my timeline. I miss the callback, though when they release the scrubber, I want to still trigger the flv to play and choose the right point in the flv.

 

Any ideas on the easiest way to accomplish this kind of checking?

 

TIA!

Link to comment
Share on other sites

One "hacky" workaround would be to throw a label on the same frame as the callback, which I could query using the currentLabel property, and based on the currentLabel, perform an action (in the case of the previous flv example, find the right position in the flv and start playing it).

 

However, given that I have other callback functions I'm utilizing as well, I'd like a more elegant solution that would be reusable in various situations (what if several callback functions should be active for a given moment in the timeline?).

Link to comment
Share on other sites

I believe the solution is simple, but first let me explain the problem: by default, gotoAndPlay() will suppress events (like onCompletes, onUpdates, callbacks, etc.) which is the behavior most developers prefer. It'd be like when a record player is playing, picking up the needle and putting it down elsewhere instead of dragging the needle across the record to the new position. You can easily change that behavior by using the 2nd parameter ("suppressEvents") of the gotoAndPlay() method, like:

 

myTimeline.gotoAndPlay(5, false);

 

Same is true for gotoAndStop();

 

Another way to do it is to simply set the currentTime instead of using gotoAndPlay().

 

Is that what you were looking for?

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