Jump to content
Search Community

Forward timeline

moxol test
Moderator Tag

Recommended Posts

How do I do forwarding to specific tween in timeline?

 

If I have:

timeline.append(tween1);

timeline.append(tween2);

timeline.append(tween3);

timeline.append(tween4);

 

and I want to forward to tween3, how to do that?

 

Also, tween1 and tween2 have tween events that need to be completed before forwarding.

Link to comment
Share on other sites

Every tween has a startTime that corresponds to the spot on its parent timeline where it begins. Are you using v12? If so, you can do something like this:

 

timeline.seek( tween3.startTime() );

 

By default, all events (like callbacks, onCompletes, etc.) will be suppressed when the playhead moves to the new spot, but if you want them to be triggered (not suppressed), use the 2nd parameter and set it to false.

 

timeline.seek(tween3.startTime(), false);

 

Is that what you were looking for? If you're using v11, the code would be slightly different, but I suspect you're using v12 (which I'd recommend).

Link to comment
Share on other sites

Every tween has a startTime that corresponds to the spot on its parent timeline where it begins. Are you using v12? If so, you can do something like this:

 

timeline.seek( tween3.startTime() );

 

By default, all events (like callbacks, onCompletes, etc.) will be suppressed when the playhead moves to the new spot, but if you want them to be triggered (not suppressed), use the 2nd parameter and set it to false.

 

timeline.seek(tween3.startTime(), false);

 

Is that what you were looking for? If you're using v11, the code would be slightly different, but I suspect you're using v12 (which I'd recommend).

 

I am using v12.

This could do, but I already found different solution, you can tell me if it's alright.

timeline.append(tween1);
timeline.append(tween2);
timeline.addLabel("tween3", timeline.duration());
timeline.append(tween3);
timeline.append(tween4);

 

and to forward I do:

 

timeline.gotoAndPlay("tween3", false);

Link to comment
Share on other sites

Hi Moxol,

 

Nothing wrong with how you are adding the label, but you can add the tween and the label at the same time like so:

 

 

timeline.append(tween1);
timeline.append(tween2);
timeline.insert(tween3, "tween3");
timeline.append(tween4);

 

When you use insert() and specifiy a label that doesn't already exist a label is automatically appended to the end of the timeline and that is where your tween will be inserted. This feature isn't well known but is documented and very handy for exactly this situation.

 

To jump to a specific label in the timeline use:

 

timeline.seek("tween3")

 

gotoAndPlay() is deprecated in v12. Best to get comfortable with the methods that are more future-proof.

  • Like 2
Link to comment
Share on other sites

Carl's and Jamie's approaches are both probably better than what I recommended (for some reason I assumed that you were asking how to do it if you only had a reference to the tween where you wanted to jump to, but if you can build it in the first place with labels, that's even better). Thanks for chiming in guys.

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