Jump to content
Search Community

Getting currentTime of TweenLite.delayedCall

peter.vullings test
Moderator Tag

Recommended Posts

Hi guys,

 

Thanks for the awesome libraries :)

Using the AS3 classes, I am trying to implement a 'pause' feature in the 'delayedCall', like so:

 

// Create the delayed call
var myCall : TweenLite = TweenLite.delayedCall( time, myFunction );
...
// Some time later, pause the call
var timeRemaining = myCall.duration - myCall.currentTime;
TweenLite.killDelayedCallsTo( myFunction );
...
// Some time later, un-pause the call
var myCall : TweenLite = TweenLite.delayedCall( timeRemaining, myFunction );

 

Problem is, myCall.duration and myCall.currentTime always return 0.

 

Any help appreciated!

 

Regards,

Peter

Link to comment
Share on other sites

Well, a delayedCall is different than a tween in the sense that there's no duration. It isn't as though a delayedCall starts at one time and then spans some time and then ends like a tween does. There are actually two ways that a delayedCall could be built - one is to use a delay on a zero-duration tween that has an onComplete. The second is to use no delay in a tween that has a non-zero duration and an onComplete. Basically the time of the delay is either in the "delay" or in the "duration". In order to maximize performance (a big emphasis for me), I use the first option ("delay") because it only renders the tween once. For example, let's say you have a 10-second delay. TweenLite simply schedules that tween to get rendered in 10 seconds. From now until then, it skips rendering the tween. If the delay is in the duration instead, that means that the tween will render on every frame between now and 10 seconds from now. It really isn't a big expense in terms of processing - it's a function call and some conditional statements on each frame. But I'm an optimization freak, so I always opt for the less processor-intensive route unless there's a compelling reason not to.

 

So in your case, since you want to be able to track how long it's been since the delayedCall was created and you want to be able to puase()/resume(), I'd recommend manually creating the delayedCall as a tween instead, like this:

 

var myCall : TweenLite = new TweenLite(myFunction, time, {onComplete:myFunction, overwrite:false});

 

You can still use TweenLite.killDelayedCallsTo( myFunction ) if you want - that's the same as doing TweenLite.killTweensOf(myFunction).

 

Does that clear things up?

  • Like 1
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...