Jump to content
Search Community

TimelineMax yoyo issues...

kipp test
Moderator Tag

Recommended Posts

Hi Jack,

I just came across an issue when setting repeat or yoyo after a timeline has already played once. This is using the most recent version of the tweening classes (11.104). It appears that changing the repeat value won't interfere with calling reverse(), but it won't actually repeat no matter what you set the value to. Setting yoyo to true prevents reverse() from working at all. I've attached an example below:

 

package{

import flash.display.Sprite;
import com.greensock.*;

public class TweenTest extends Sprite {

protected var _ani:TimelineMax = new TimelineMax();

public function TweenTest():void {
	var s:Sprite = addChild(new Sprite()) as Sprite;
	s.graphics.beginFill(0xCC0000);
	s.graphics.drawCircle(0,0,40);
	s.x = stage.stageWidth * .5;
	s.y = stage.stageHeight * .5;

	_ani.insert(TweenMax.from(s, 2, { alpha:0 }));

	TweenMax.delayedCall(4, changeRepeat);
}

public function changeRepeat():void {
	trace("Animation should now alpha out and then alpha in again, but appears to be tired of tweening.")
	_ani.repeat = 1;
	_ani.yoyo = true;
	_ani.reverse();
}
}
}

 

Any ideas? Thanks a bundle!

-Kipp

Link to comment
Share on other sites

Nope, this isn't a bug. Let me explain: you created a timeline containing a 2-second tween and no repeats, so it plays the one tween and reaches the end in 2 seconds. Fine. No trouble. Keep in mind that the timeline's currentTime and totalTime would be 2 at the end. So then you change repeat to 1 and set yoyo to true and reverse(), so it goes from a currentTime and totalTime of 2 back to 0. Done - it's not supposed to go beyond that. When you set a repeat value, it is always measured from the beginning, so for example, if your timeline is 2 seconds long and you set a repeat of 1 (assuming repeatDelay is 0), your timeline will now last 4 seconds. When you play forward, you'll see the totalTime go from 0 to 4 and the currentTime will go from 0 to 2 twice. In your scenario, your timeline was stopped at a totalTime of 2 when you reversed. Is it making sense now?

 

If you want to force it to the end and make it play in reverse for both cycles, you can easily do that my setting the timeline's totalProgress = 1 or set the totalTime = totalDuration, then reverse().

Link to comment
Share on other sites

Ah, that's making more sense now. Thanks for taking the time to explain it to me. :)

 

So I play through my timeline and it stops, then later when I change the repeat to 1, that effectively makes the totalProgress = .5. Now if I resume at this point, shouldn't my timeline progress backwards until it gets to 0? If I change the following lines in the previously posted code, the animation jumps directly to alpha = 0.

 

Am I still missing something?

 

public function changeRepeat():void {
_ani.repeat = 1; // _ani.totalProgress = .5 as a result of this.
_ani.yoyo = true;
_ani.resume(); // Should fade from current alpha to 0
}

 

Thanks for the help!

-Kipp

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