Jump to content
Search Community

Missing onReverseComplete with TimelineMax

Panel test
Moderator Tag

Recommended Posts

Hello

 

I need to know when tween animation ends if animation is reversed.

This seend work fine when using single tween, but when I am using TimelineMax onReverseComplete isn't called at all ;/

To clarufy at first I am runing whole tween and then using _timeline.play(); and then (after it's completion) I am using _timeline.reverse();

 

_timeline = new TimelineMax();
_timeline.append(new TweenMax(r, 0.5, {x:100, onComplete:onComplete, onReverseComplete:onReverseComplete}));
_timeline.append(new TweenMax(r, 0.5, {y:200, onComplete:onComplete, onReverseComplete:onReverseComplete}));
_timeline.pause();

 

It it a bug?

Is there any solution for this?

Link to comment
Share on other sites

nope, not a bug. greensock addresses this issue best

 

For the record, the reason the onReverseComplete stuff wasn't firing was because your tweens weren't reversed. The TimelineMax in which you nested them was reversed, but that doesn't reverse the tweens themselves. If you reverse tweens inside a reversed TimelineMax, they'd appear to go forwards (reversing reversed = forwards). I know, it can get a little confusing. If you need a function to get called at a particular time on a TimelineMax regardless of direction (reversed or not), just use addCallback().

 

viewtopic.php?f=1&t=1635&p=13304&hilit=onReverseComplete#p13304

 

so, use addCallback() as he suggested, if you need the callback only to fire when the timeline is reversed you can add a conditional to your callBack...

 

import com.greensock.*;
import com.greensock.easing.*;

var tl:TimelineMax = new TimelineMax({onComplete:playBackwards});

tl.append(TweenMax.to(mc, 1, {x:400 }));
tl.addCallback(onlyOnReverse, tl.duration);
tl.append(TweenMax.to(mc, 1, {y:400 }));

function onlyOnReverse(){

if(tl.reversed){
	trace("ok i'm going backwards, let's do something");
	}else{
		trace("moving forwards, ignore...");
		}
}

function playBackwards(){
tl.reverse();
}	

Link to comment
Share on other sites

  • 1 month later...

Hello Carl

thax for the answer

 

I am getting the point, but for me the idea is strange.

 

Yes tweens aren't reversed, but the truth is that they are playing backwards, so they are playing reverse (kind of).

Since tween is playing (regardless if it's reversed or not) there should be some event notifying of tween completion and now this event isn't available since onComplete nor onReverseComplete isn't fired ;/

 

Live example:

I have app where user i able to click next and tween is playing animating things on stage to some point ().

tween1-> STAGE1 -> press next -> tween2-> STAGE2 -> press next - > tween3 -> STAGE3

 

Now if I would like to return to STAGE2 I can reverse tween but I don't know when to pause it (event here would be nice).

 

The problem with add callback is that it isn't precise (although according time is should be) and tweens simply ends to early witch looks creepy when easing is enabled.

Link to comment
Share on other sites

I am confused about how the addCallback()'s are not firing at precise times, but another option would be to use TimelineMax's tweenTo() method in conjunction with labels before each "stage" or "section" of your animation:

 

http://www.greensock.com/as/docs/tween/ ... l#tweenTo()

 

you could even use the getLabelAfter() and getLabel() before methods to dynamically fetch the next label in your sequence

 

i am particularly fond of this discussion on working with labels in TimelineLite/Max

 

http://active.tutsplus.com/tutorials/an ... th-labels/

Link to comment
Share on other sites

The problem with add callback is that it isn't precise (although according time is should be) and tweens simply ends to early witch looks creepy when easing is enabled.

I'm very curious about this - can you post a very simple example FLA that demonstrates this? I can't imagine how/why the addCallback() wouldn't be just as precise as any other tween (an addCallback() is in fact just adding another special tween). Also, a tween should never "just end early" - I'm super curious to see this too.

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