Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
friendlygiraffe

tweenTo duration ?

Recommended Posts

Hi, I'm tweening a timeline to a label but there doesn't seem to be any way of controlling the duration

myTimeline.tweenTo("zoom1");

I want something like this, 3 seconds

TweenMax.to(myTimeline, 3 ,{tweenTo:"zoom1"})

Is it possible?

Link to comment
Share on other sites

Absolutely. Here's the easy answer:

myTimeline.tweenTo("zoom1").duration(3); 

But just so you know, tweenTo() method is just a convenient way to tween the timeline's "time" value, so under the hood it is basically doing something like this:

//first pause the timeline so that it doesn't keep trying to update itself - our tween will drag the playhead
yourTimeline.pause();

//figure out the destination time (let's assume you passed in a label):
var time:Number = yourTimeline.getLabelTime(label); 

//figures out the duration automatically, assuming you want the timeline to play at normal speed linearly
var duration:Number = Math.abs(time - yourTimeline.time()); 

//now spit back the tween:
return TweenLite.to(yourTimeline, duration, {time:time, ease:Linear.easeNone});

So you're welcome to do that kind of thing yourself directly instead:

yourTimeline.pause();
TweenLite.to(yourTimeline, 3, {time:yourTimeline.getLabelTime("zoom1"), ease:Linear.easeNone});
  • Like 1
Link to comment
Share on other sites

Thanks a lot for your reply.

 

I didn't have any luck, using the last one. I get this error:

timeline.pause();
TweenMax.to(timeline, 2, {time:timeline.getLabelTime("zoom1"),ease:Quart.easeOut});

 

Error #1069: Property time not found on com.greensock.TimelineMax and there is no default value.

 

Link to comment
Share on other sites

Oh, are you using the old v11 stuff? Please make sure you update to version 12 if at all possible: http://www.greensock.com/v12/. If you need to use v11, you'd need to reference "currentTime" instead of "time". 

Link to comment
Share on other sites

Hi, sorry for the confusion. You can get the latest versions of v11 or v12 from that page. Take a look at the text under the word "important" up top. Hopefully that clears things up.

 

Chances are you went right for the AS3 button without reading... totally understandable. 

Link to comment
Share on other sites

Ah I should pay more attention. Thanks for your help

Link to comment
Share on other sites

  • 7 months later...

Apologies for bringing up an old topic, but just want to point out to anyone else who finds this thread that this syntax:

myTimeline.tweenTo("zoom1").duration(3);

Doesn't work - the tween continues at the previous duration, even though the duration property reports back the changed value. You have to manually do it as was posted above:

timeline.pause();
TweenMax.to(timeline, 2, {time:timeline.getLabelTime("zoom1"),ease:Quart.easeOut});
Link to comment
Share on other sites

Ah yes, thanks for pointing that out - it'll be fixed in the next update. If you'd like an early preview, just let me know. 

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