Jump to content
Search Community

TimelineMax's issue with delayedCall

cardinal4 test
Moderator Tag

Recommended Posts

I've found TweenLite's delayedCall methods to be extremely useful in scripting delays, much more useful than setInterval or enterFrame with getTimeElapsed().

 

I thought of bringing it one step further by substituting TweenLite on my enterFrame, but it seems TweenLite/TimelineMax has some issues.

 

As illustrated in the following code:

1. With infinite repeat, a delay call of 1 frame fails.

- It succeeds if the repeat is removed.

- Or if the delay is bigger than 1 frame.

2. But if a second delay is pegged on, it works!

 

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

public class Main extends Sprite 
{
	public function Main():void 
	{
		// Calling with Frame <= 1 fails.
		var timeline1:TimelineMax = new TimelineMax({ repeat: -1, useFrames: true });
		timeline1.append(TweenLite.delayedCall(1, trace, ["-> 1"]));
		timeline1.play();

		// Pegging timeline1 with further calls on Frame > 1 succeeds
		var timeline3:TimelineMax = new TimelineMax({ useFrames: true });
		timeline3.append(TweenLite.delayedCall(1, trace, ["---> 3"]));
		timeline3.append(TweenLite.delayedCall(2, null));
		timeline3.play();
	}
}
}

 

In a side note, I was wondering if there was a way to activate 2 Tweens at the same moment in time. For example, I want to have the Second Call come in after the First Call. In the order at which they were appended. Is it possible?

		var timeline4:TimelineMax = new TimelineMax({useFrames: true});
		timeline4.append(TweenLite.delayedCall(2, trace, ["First"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Second"]));
		timeline4.play();

Link to comment
Share on other sites

Hmm, it strikes me as a bit wasteful to use a delayedCall to replace ENTER_FRAME event handlers. Why would you want to? Help me understand why you thought this was beneficial.

 

There was an issue with repeated TweenMax/TimelineMax instances rendering at their start time instead of the end time when the virtual playhead was placed exactly on top of a repeat point, but that is resolved in the latest version. Thanks for pointing this out. Please update to the latest version and let me know if it resolves things for you. http://www.TweenMax.com

Link to comment
Share on other sites

Why I wanted to peg my EnterFrame listeners onto a looping delayedCall, is kinda because of lazy. :lol:

 

Because I needed a convenient way to pause/resume an animation of a Popup, which culminated in a TextField that pulsed in the background. That pulsing used to rely on enterFrame, and the rest of the animation on TimelineMax. So I thought, might as well lay everything on TimelineMax, and pause everything with a simple TimelineMax.pause().

 

Yup, I think the previous issues are resolved, thank you. :)

 

The below still doesn't work, but it's because the playhead is exactly over the repeat as you mentioned, am I getting it right?

var timeline1:TimelineMax = new TimelineMax({ repeat: -1, useFrames: true });
		timeline1.append(TweenLite.delayedCall(1, trace, ["-> 1"]));
		timeline1.play();

 

I've another question, is that whether the below code will always execute in the same order everytime (eg. there isn't a race condition where the order in which it is called gets jumbled up at the whim of the Flash AVM).

var timeline4:TimelineMax = new TimelineMax({useFrames: true});
		timeline4.append(TweenLite.delayedCall(2, trace, ["First"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Second"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Third"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Fourth"]));
		timeline4.play();

Link to comment
Share on other sites

...whether the below code will always execute in the same order everytime (eg. there isn't a race condition where the order in which it is called gets jumbled up at the whim of the Flash AVM).

var timeline4:TimelineMax = new TimelineMax({useFrames: true});
		timeline4.append(TweenLite.delayedCall(2, trace, ["First"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Second"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Third"]));
		timeline4.append(TweenLite.delayedCall(0, trace, ["Fourth"]));
		timeline4.play();

 

The engine will always render things consistently - you don't need to worry about the Flash Player suddenly shuffling things around once in a while.

 

As for the other single-frame TimelineMax question, that doesn't fire onComplete on every frame because it only does so when the virtual playhead arrives on that particular position, just like a frame action on a MovieClip timeline. It won't play when it leaves that frame (it wouldn't make sense to do so). So your repeating single-frame TimelineMax triggers the onComplete once but then when it repeats, it goes right back to the end frame (as it should) and since it's already there, there was no change and it doesn't fire the onComplete. Exactly like when you have a single-frame MovieClip - it doesn't play its actions over and over again. Sorry if I'm doing a poor job of explaining it, but trust me - this is expected behavior :)

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