Jump to content


TimelineMax delayedCall a function with other TweenMax

Recommended Posts



I'm using the TimelineMax ans it works great. But I have a problem with something. I want to use a delayedCall function. In this function, I have other tweenMax. Something like this :

var tl:TimelineMax = new TimelineMax();
tl.insert(TweenMax.to(camion, 8,{x:700, ease:Linear.easeNone}));
tl.insert(TweenMax.to(nuage, 20,{x:"-100", ease:Linear.easeNone}));
function enleverTexte() {
	TweenMax.to(txt1, 0.7,{y:"-40", alpha:0, ease:Quint.easeIn});
	TweenMax.to(txt2, 0.7,{y:"-40", alpha:0, ease:Quint.easeIn, delay:0.2});

Now, I want to start my animation with a gap starting. Like this :

tl.currentTime = 5;

Normaly, I should not see the movieClip txt1 ans txt2 when my animation start (because I launch the animation at 5 seconds, and inside my timeline I hide the mc txt1 and txt2 at 3 seconds).


But it doesn't works... When the animation start, even if I start at 15 seconds, I see the mc txt1 and txt2 and the function enleverTexte() is executed...


How can I do this kind of manipulation ? Thank you.

Link to comment
Share on other sites

The problem is that you're merely putting the function call into the timeline, not the actual alpha tweens themselves, so when you jump to the 5-second spot, the playhead sees that it passes that delayedCall in the timeline and immediately calls it (which is exactly what it's supposed to do) and in that function you're starting your alpha tweens. See the problem? It's logically impossible to retroactively call that function 2 seconds in the past ;)


The solution would be to simply put those tweens directly into the TimelineMax rather than wrapping them in a function that you're calling with a delayedCall.


I'd also highly recommend switching to v12 of the platform (it looks like you're using v11). There are some convenience methods that'll make your code more concise. Here's how it'd look in v12:

var tl:TimelineMax = new TimelineMax();
tl.to(camion, 8, {x:700, ease:Linear.easeNone})
  .to(nuage, 20, {x:"-100", ease:Linear.easeNone}, 0)
  .to(txt1, 0.7, {y:"-40", alpha:0, ease:Quint.easeIn}, 3)
  .to(txt2, 0.7,{y:"-40", alpha:0, ease:Quint.easeIn}, 3.2);

//then later...
Link to comment
Share on other sites

Thank you Jack,


You are right, it's exactly what it's supposed to do :)

Of course, I thought about your solution and for this particular case I can do it this way.

But I would find another system because since I use your tweenMax Classes I took the habits to use a lot of delayedCall for big animations with lot of tweenMax...


For example, imagine I have to play a sound at 3 seconds inside my timeline.

So I need to call a function at 3 seconds.

If I set the start time of my timeline a 5, does the sound will be played immediately?


Which code would you use for this case?


PS : thanks for the V12 trick, I will switch!

Link to comment
Share on other sites

You could do it either way. Think of moving the playhead like the needle on a record player - you could pick it up and drop it into a new spot, or you could DRAG it across the record to the new spot which means it'd contact everything inbetween. When you seek() or set the time() or totalTime(), you're moving the playhead and those methods all accept a "suppressEvents" parameter so that you can control whether or not it calls any callbacks/events inbetween the old and new positions. So, for example, if you've got a delayedCall at 3-seconds and you want to jump to the 5-second spot WITHOUT calling that function, you could do:

yourTimeline.seek(5, true);

Or you could use yourTimeline.time(5, true) or yourTimeline.totalTime(5, true). Any of those should work just fine. 


Or set it to false if you do want all the callbacks inbetween to get triggered. 

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.