Jump to content
GreenSock

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

killAll/reverse bug (unhandled situation)

Recommended Posts

Hi guys,
 
I have a problem with The TweenMax.killAll(true) method. Here is my example:

TweenMax.to(targetQ, 2, {
scaleX : 2,
scaleY : 2,
reversed : true,
yoyo : true,
repeat : 1,
x : targetQ.x + (targetQ.width - 2 * targetQ.width) / 2,
y : targetQ.y + (targetQ.height - 2 * targetQ.height),
ease : Back.easeOut,
onReverseComplete : function onReverseComplete():void {
trace("complete this tween ;)");
}
} );
 
If you make a reversed tween, it's never call the onComplete function.
The tweenax documentation write this: "
  • onComplete : Function – A function that should be called when the tween has completed. To sense when a tween has reached its starting point again after having been reversed, use onReverseComplete.
"


If I call TweenMax.killAll(true), tween not killed!!!!!
 
As I see, the problem is in the killAll method.
 
Inside this, here's a line:
isDC = (a.target == a.vars.onComplete);
 
Unfortunately, if you set a reverse to a tween, onComplete callback ignored!
 
cheers,
jax
 
Link to post
Share on other sites

When you say the tween isn't killed, do you mean that it continues to run? Or that it doesn't fire its onReverseComplete? 

 

Keep in mind that in GSAP, onComplete is direction-specific meaning that it's at the end of a forward-running animation whereas onReverseComplete fires when the virtual playhead reaches the beginning of a tween/timeline after having been reversed. So technically your onReverseComplete should NOT be fired in your example so as far as I understand this is all expected behavior (unless you're saying that your tween keeps running after being killed). 

 

I can definitely see a valid argument for killAll() looking at the orientation of each tween and if it's reversed, make it go to the beginning instead of the end when the "complete" parameter is true. I'll add that to the next update of GSAP. Let me know if you'd like an early copy to test the functionality. 

 

PS. that isDC = (...) was definitely not the cause of the problem. That's just something that identifies if the tween is a delayedCall. 

Link to post
Share on other sites

"When you say the tween isn't killed, do you mean that it continues to run?"

Yes.

 

Or that it doesn't fire its onReverseComplete? 

Yes.

 

I made a test for you, but where can I attach?

 

PS. that isDC = (...) was definitely not the cause of the problem.

Okay, I'm just read into the code quickly...

 

 

Ps. I found one another bug. I download again the as3 version. (last changelog date is 2012-06-30)

 

There is a warning in the Tweenlite.as:

 

com\greensock\TweenLite.as:406: Warning: Assignment within conditional.  Did you mean == instead of =?

 

(siblings = masterList[this.target])

 

I fixed it to:

 

(siblings == masterList[this.target])

Link to post
Share on other sites

I'd love to see an example, yes. You can click the "More Reply Options" button below to get to a screen where you can attach a file. Please make sure you zip it first. 

 

It sounds like you're using a very old version of GSAP - I strongly recommend that you use the latest v12 stuff. Read about it here: http://www.greensock.com/v12/

 

You posted your question in the JavaScript forum, but I assume you're using the ActionScript 3 flavor, right? 

 

As for that other "bug" you mentioned, that's not a bug at all. It's perfectly valid ActionScript and it's in fact a performance optimization. It's killing two birds with one stone - it assigns a value to a variable AND verifies that it's not null. DO NOT apply your "fix" because that would break the code, causing it to do a completely different thing altogether. Your code checks to see if the two values are equal instead of assigning the value properly and doing the conditional null/zero check. 

 

Notice that Flash classified that as a "warning", not an "error" because it is in fact a common mistake that people could make (typing "=" instead of "==" inside a conditional statement) but in this case, it's not a mistake at all. 

  • Like 1
Link to post
Share on other sites

Ah, I download from here:

http://www.greensock.com/tweenmax/

 

 

I download the v12, but there are more warnings (from flashdevelop):

com\greensock\TweenMax.as:1636: Warning: Assignment within conditional.  Did you mean == instead of =?
com\greensock\TweenMax.as:1636: Warning: Assignment within conditional.  Did you mean == instead of =?
com\greensock\plugins\TweenPlugin.as:158: Warning: Assignment within conditional.  Did you mean == instead of =?
com\greensock\plugins\TweenPlugin.as:285: Warning: Assignment within conditional.  Did you mean == instead of =?
com\greensock\plugins\TweenPlugin.as:290: Warning: Assignment within conditional.  Did you mean == instead of =?
 
if (allTrue || (tween is SimpleTimeline) || ((isDC = (TweenLite(tween).target == TweenLite(tween).vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
                                             ^
if ((ar = this._autoRotate)) {
    ^
if (end != null && (c = (typeof(end) === "number" || end.charAt(1) !== "=") ? Number(end) - start : int(end.charAt(0)+"1") * Number(end.substr(2)))) {
                   ^
if ((pt._prev = pt2 ? pt2._prev : last)) {
    ^
if ((pt._next = pt2)) {
    ^
Build halted with errors (fcsh).
 

 

Ok, I add a test with the old version. The new version upload skiped (too big file).

old.zip

Link to post
Share on other sites

And yes, sorry, I doesn't wacth the subtitle. This is a flash as3 problem!

Link to post
Share on other sites

Sorry, but we don't actively support such an old version of the platform. It looks like that very likely was a bug back then, but it has been resolved in v12. I tested your file and it worked perfectly for me. No errors, no warnings, and the expected behavior. 

 

If Flashdevelop is refusing to compile because of "warnings" about those assignments, that's a problem with Flashdevelop, not GSAP. Like I said, it compiles perfectly from Flash and I'm positive that it's valid ActionScript. I think Flashdevelop is attempting to be "helpful" with its prompts, but it's doing quite the opposite. 

 

If Flashdevelop won't work, perhaps you should try a different tool that compiles correctly?

Link to post
Share on other sites

Hm. Okay, maybe the warnings are flashdevelop problems. But I was attach an fla version qiuck test. If I push the killAll button, tweens doesn't stop!

If I use the v12 version, killAll restart the tweens.

Link to post
Share on other sites

Other way, the assign and compare function not the best. I make a quick test:

 

var m:Array;
var test:Array = [1,2,3];
 
trace(true && (m = test)); // output: 1,2,3
trace((true && (m = test) && true)); // output: true
trace((true && (m = test) && false)); // output: false
Link to post
Share on other sites

Your first line was missing a ")". 

 

I'm not sure what your point is with those tests - that's exactly what the expected behavior is. What am I missing? Why do you think it's "not the best"? 

 

I'm looking into the killAll() restarting the tweens - I was testing with the updated version of TweenMax which had the behavior you wanted, but I reverted to see what you were talking about with the yoyo'd repeating reversed tween not being killed properly. I should be able to get you an answer tomorrow. 

Link to post
Share on other sites

Yes, this emoticons kidding me, I fixed the trace post. :)

Link to post
Share on other sites

I found exactly what the problem was and it would only affect reversed tweens (as you discovered). I have attached a preview of the upcoming TweenMax update which should resolve things. Sorry about any confusion/hassle. Please let me know if it works well for you. 

TweenMax_12.1.5_preview.zip

  • Like 1
Link to post
Share on other sites

Thx. It's work with fla. Flashdevelop return errors, but!

 

As I said, the assign and compare method not the best:

 

var m:Array;
var test:Array = [1,2,3];
 
trace((true && (m = test))); // output: 1,2,3
 
trace(true && Boolean(m = test)); // output: true
trace(false && Boolean(m = test)); // output: false
 
trace((true && (m = test) && true)); // output: true
trace((true && (m = test) && false)); // output: false
Link to post
Share on other sites
Okay, I change the problematics lines like this:
 
if (allTrue || (tween is SimpleTimeline) || ((isDC = (TweenLite(tween).target == TweenLite(tween).vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
 
 
change to:
 
if (allTrue || (tween is SimpleTimeline) || (Boolean(isDC = (TweenLite(tween).target == TweenLite(tween).vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
 
 
Assign an array to another, the return value not casted automaticly to boolean!
Now it's work in flashdevelop too.
 
Link to post
Share on other sites

The casting is not necessary, but if you like it there and Flashdevelop prefers it, great. 

 

For the record, conditional logic isn't limited to booleans. 

 

Glad to hear the latest version works well for you. Cheers!

Link to post
Share on other sites

You could also disable warnings in the project's settings for the Flex compiler, or if you are a club member - try the pre-compiled .swc instead of the loose files.

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

×