moxol Posted October 11, 2012 Share Posted October 11, 2012 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 More sharing options...
GreenSock Posted October 11, 2012 Share Posted October 11, 2012 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 More sharing options...
moxol Posted October 12, 2012 Author Share Posted October 12, 2012 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 More sharing options...
Carl Posted October 12, 2012 Share Posted October 12, 2012 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. 2 Link to comment Share on other sites More sharing options...
jamiejefferson Posted October 12, 2012 Share Posted October 12, 2012 That is my preferred solution as well, and because of the flexibility of the append function, you could even write that as timeline.append("tween3"); edit: my reply was to moxol, but Carl posted at the same time as me Link to comment Share on other sites More sharing options...
GreenSock Posted October 12, 2012 Share Posted October 12, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now