Jump to content
GreenSock

dorkbot

killTweensOf not working, and there is no longer a complete param?

Recommended Posts

Hi,

 

This is not working for me:

 

 

TweenMax.from(this, 33, {colorTransform:{tint:0xC7DDC6, tintAmount:0.3}});

TweenMax.killTweensOf(this);

 

 

The tween continues and works, but shouldn't it be killed? And I've noticed there is no complete parameter. Isn't there suppose to be?

 

This does stop the tween:

 

 

TweenMax.from(this, 33, {colorTransform:{tint:0xC7DDC6, tintAmount:0.3}});

TweenMax.killAll(true);

 

I want to stop all and complete all tweens of an object before assigning another tween to it. So something likes this:

 

 

TweenMax.killTweensOf(this);

TweenMax.from(this, 33, {colorTransform:{tint:0xC7DDC6, tintAmount:0.3}});

 

And I want the object to complete during the kill.

 

Thanks!

 

Link to comment
Share on other sites

Yes, the behavior of killTweensOf has changed in v12 as noted in the release notes:

 

feature 26

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.

http://www.greensock.com/v12/

 

As noted above, here is an example of forcing tweens to completion prior to the kill:

 

 

TweenMax.from(this, 33, {colorTransform:{tint:0xff0000, tintAmount:1}});


//fire the kill after 1 second
TweenLite.delayedCall(1, kill);


function kill():void {
    //get all tweens of this
    var tweens:Array = TweenMax.getTweensOf(this);
    var len:int = tweens.length;
    trace(len);//1
    for (var i = 0; i<len; i++) {
        //force all tweens to the end
        //if you know they are TweenMaxes, just set progress(1);
        tweens[i].seek(tweens[i].duration());
    }
    TweenMax.killTweensOf(this);
    //look no more tweens
    trace(TweenMax.getTweensOf(this).length); ///0
}
 

 

Let us know if you have any trouble implementing this

Link to comment
Share on other sites

And by the way, you said that the killTweensOf() wasn't working for you when you put it right after your from() tween - is that correct? Did you continue to see the tween animating or did you just mean that the from() starting values were applied? They should be applied because remember, from() tweens have immediateRender:true set by default because that's typically the desired behavior. So in your example, as soon as you created that from() tween, it rendered its starting values and then when you killTweensOf(), it killed the tween, but that doesn't mean it reverts the values before it kills the tween - it just kills it wherever it is. In your case, it was killed in its starting state. 

 

Does that clear things up? Like Carl said, you should be able to grab the associated tweens and force them to completion (or any point) using getTweensOf() and a loop. 

Link to comment
Share on other sites

So can you always use TweenMax.getTweensOf(this); even if you started the tween with TweenLite? Or would I have to use TweenLite.getTweensOf(this); ?

 

cheers

Link to comment
Share on other sites

Yep, TweenMax.getTweensOf() is just an alias for TweenLite.getTweensOf() - they both pull from the central tween database (of sorts). 

Link to comment
Share on other sites

  • 2 months later...

Ok, but what if we're using TweenNano? Nano doesn't seem to support getTweensOf();

Link to comment
Share on other sites

That's correct. TweenNano is built to be EXTREMELY small, so certain features must be sacrificed.

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