Jump to content

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

Force Tweens completion

Recommended Posts

I was playing with killTweensOf, and after a few hours of problems I discovered that the documentation is not updated correctly between v11 and v12 (it reports a "complete" parameter that does not exist anymore in v12), that the version I was using was sufering of a bug (the second parameter was an Object intead of a Boolean as declared in the documentation;,updating the libs it has been fixed, but...), and that the second parameter in the new libs version is not "complete" anymore, but "onlyActive"!

What a mess!

I now wonder if to force tweens completion before killing them I have to use the function you suggested in this thread




or if there is a built-in function to automate it. Why did you remove the complete parameter?



Link to comment
Share on other sites

Sorry to hear about the confusion. Let me clarify a few things:

  1. As far as I know, the docs for v12 have been correct from the get-go, but I wonder if you were looking at the v11 docs and assumed they applied to v12. Note that the v12 docs are at http://api.greensock.com/as/ (and all the v12-related pages link there) but we left the v11 docs online for legacy support at http://www.greensock.com/as/docs/tween/. 
  2. On the big v12 launch page, we listed out all of the changes and made special note of things that could affect legacy code: http://www.greensock.com/v12/. Notice #26 in the list:
The complete parameter of killTweensOf() has been removed because it created confusion when only specific properties were defined using the vars parameter. For example, if the old method was called like TweenLite.killTweensOf(myObject, true, {y:true}), was the whole tween supposed to be forced to completion or only the y property? Adding the ability to only force the y property to completion would require too much kb (file size) and it wouldn’t solve the confusion issue, so I removed the parameter altogether. If you want to force all the tweens of a particular object to completion, simply use the TweenLite.getTweensOf() to get an array of them, and loop through it and do myTween.seek( myTween.duration() ) first.



Hopefully our reasoning makes sense (we try REALLY hard not to change the API in ways that could affect legacy code whenever possible, but sometimes the benefits outweigh the costs and in an effort to modernize and mature the platform, we make some strategic decisions like this).


You can create your own function that accomplishes what you're after like this:

function killAndCompleteTweensOf(target:Object):void {
    var tweens:Array = TweenLite.getTweensOf(target);
    var i:int = tweens.length;
    while (--i > -1) {
        tweens[i].totalTime( tweens[i].totalDuration() ).kill();

Does that clear things up?

Link to comment
Share on other sites

Well, yes, I was looking at v11 docs... ok, no problem, I have fixed the problem and I will use the new function to complete/kill the tweens.


I read the launch page a few months ago, but it was so full of infos that I missed/forgot the part about killTweensOf, sorry.


If only I have had the updated libs from the beginning I would have immediately seen the different name of the second parameter... I am unlucky today  :|


Thank you Jack!

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.