Jump to content
GreenSock

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

Pausing in between tweens AS2

Recommended Posts

I'm using the append (Timeline lite) method to have one tween start after the next, also with a few delay adjustments, I want to pause between tweens so the movie clip stays on the stage for a few seconds before the next tween happens, I'm using AS2, can someone help a newbie? Thanks!

 

 

import com.greensock.*;

import com.greensock.easing.*;

 

var tl:TimelineLite = new TimelineLite({onComplete:done})

 

tl.append( TweenLite.to(image_mc, 1, {_x:-300, _y:0, ease:Quint.easeIn}));

tl.append( TweenLite.to(lafrom_mc, 1, {_x:20, _y:33, delay:-1, ease:Quint.easeIn}));

tl.append( TweenLite.to(logos_mc, 1, {_x:110, _y:185, delay:-1,ease:Quint.easeIn}));

tl.append( TweenLite.to(lafrom_mc, 1, {_x:-300, _y:33, ease:Quint.easeIn}));

tl.append( TweenLite.to(toFind_mc, 1, {_x:20, _y:33, delay:-1, ease:Quint.easeIn}));

tl.append( TweenLite.to(toFind_mc, 1, {_x:-300, _y:33, ease:Quint.easeIn}));

tl.append( TweenLite.to(logos_mc, 1, {_x:-280, _y:185, delay:-1,ease:Quint.easeIn}));

tl.append( TweenLite.to(image2_mc, 1, {_x:0, _y:0, delay:-1, ease:Quint.easeIn}));

 

 

function done(){

tl.restart();

}

Link to comment
Share on other sites

I've sorted it with some extra delays in there but it seems a little counter intuitive...

 

 

import com.greensock.*;

import com.greensock.easing.*;

 

var tl:TimelineLite = new TimelineLite({onComplete:done})

 

tl.append( TweenLite.to(image_mc, 1, {_x:-300, _y:0, delay:3, ease:Quint.easeIn}));

tl.append( TweenLite.to(lafrom_mc, 1, {_x:20, _y:33, delay:-1, ease:Quint.easeIn}));

tl.append( TweenLite.to(lafrom_mc, 1, {_x:-300, _y:33, delay:3,ease:Quint.easeIn}));

tl.append( TweenLite.to(logos_mc, 1, {_x:110, _y:185, delay:-5,ease:Quint.easeIn}));

tl.append( TweenLite.to(toFind_mc, 1, {_x:20, _y:33, delay:-1, ease:Quint.easeIn}));

tl.append( TweenLite.to(toFind_mc, 1, {_x:-300, _y:33, delay:3, ease:Quint.easeIn}));

tl.append( TweenLite.to(logos_mc, 1, {_x:-280, _y:185, delay:-1,ease:Quint.easeIn}));

tl.append( TweenLite.to(image2_mc, 1, {_x:0, _y:0, delay:-1, ease:Quint.easeIn}));

 

 

function done(){

tl.restart();

}

Link to comment
Share on other sites

Hi cracknell,

Welcome to the Greensock forums! Glad to see you're getting stuck in and troubleshooting your code.

 

Using delay's is the correct way to 'pause' as you say between tweens, however, TimelineLite has it's own method for delays which might help you slightly.

 

tl.append( TweenLite.to(image_mc, 1, {_x:-300, _y:0, ease:Quint.easeIn}),3);
tl.append( TweenLite.to(lafrom_mc, 1, {_x:20, _y:33, ease:Quint.easeIn}),-1);
tl.append( TweenLite.to(lafrom_mc, 1, {_x:-300, _y:33, ease:Quint.easeIn}),3);
tl.append( TweenLite.to(logos_mc, 1, {_x:110, _y:185, ease:Quint.easeIn}),-5);
tl.append( TweenLite.to(toFind_mc, 1, {_x:20, _y:33, ease:Quint.easeIn}),-1);
tl.append( TweenLite.to(toFind_mc, 1, {_x:-300, _y:33, ease:Quint.easeIn}),3);
tl.append( TweenLite.to(logos_mc, 1, {_x:-280, _y:185, ease:Quint.easeIn}),-1);
tl.append( TweenLite.to(image2_mc, 1, {_x:0, _y:0, ease:Quint.easeIn}),-1);

 

Note how the 'delay' values are outside the tween. This value essentially tells the timeline how many seconds after the previous tween to append itself.

So if you leave it blank, the tween will happen directly after the previous tween has finished.

 

One thing that might make things easier in the future should you wish to update the timings is that the logos_mc has a delay of -5, which actually starts it off before the second lafrom_mc, so might be worth switching those around.

 

I'm not sure how much you have read or coded with Greensock and TimelineLite/Max so apologies if I'm covering old ground for you, however Jack has provided some excellent Documentation on TimelineLite and Carl Schoof has recently created a fantastic 4 part series on the basics of TimelineLite, you should check it out.

 

I hope that helps?

 

X10

Link to comment
Share on other sites

I want to pause between tweens so the movie clip stays on the stage for a few seconds before the next tween happens

 

yes, the way to pause between tweens is to add delays (as you have) or offset values (as X10's method uses) to the tweens. You are already using delays so I assume that you are referring to the time that elapses before the timeline repeats?

 

if so, give this a try:

 

function done(){

//wait 4 seconds before the timeline's restart method is called

 TweenLite.delayedCall( 4, tl.restart);
}

 

-carl

 

ps. X10, thanks for the support!

Link to comment
Share on other sites

That does help me a lot guys, thanks. I'll start watching the videos too : :)

Link to comment
Share on other sites

cool, just a note don't be turned off by the fact that the videos use as3 all the properties, methods and basic theory is exactly the same as the AS2 version.

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