PDA

View Full Version : delay a tween


grammer
11-01-2009, 09:20 AM
import fl.transitions.Tween;
import fl.transitions.easing.*;

var homemanTween:Tween = new Tween(homeman_mc, "x", Elastic.easeOut, 1000, 50, 3, true);//frist tween


var adobeTween:Tween = new Tween(adobe_mc, "alpha", Regular.easeOut, 0, 1, 3, true);//second tween

Hey people how can I animate the 2nd tween after 3 seconds when 1st tween stops.

Thanks

grammer
11-01-2009, 12:45 PM
help me out !:cool:

Striker9099
11-01-2009, 01:27 PM
ok I am not sure but maybe you can add a MOTION_FINISH event listener to the first tween, inside this handler add a timer which goes on for one time and inside the timer event handler add the second tween... donno that's all I could think of right now

box86rowh
11-01-2009, 01:53 PM
how about looking into the TweenMax class from Greensock, this will allow you to delay tweens easily.

Striker9099
11-01-2009, 03:00 PM
TweenMax does that? could you please tell us how? Thanks...

greensock
11-02-2009, 06:12 AM
Sure, just use the delay special property:

TweenMax.to(homeman_mc, 3, {x:50, ease:Elastic.easeOut});
TweenMax.to(adobe_mc, 3, {alpha:1, delay:3});

You could use TweenLite instead if you want (TweenMax just extends TweenLite, adding features). And if you need to define the starting and ending values, just use the TweenMax.fromTo() method.

You may want to check out the new TimelineLite and TimelineMax tools in v11 of the platform because they make sequencing really easy and powerful.

http://blog.greensock.com/v11/
http://blog.greensock.com/timelinelite/
http://blog.greensock.com/timelinemax/

Docs: http://www.greensock.com/as/docs/tween/

grammer
11-02-2009, 02:24 PM
thanks people. anymore ?

panel
11-02-2009, 02:37 PM
@greensock just gave you complete solution. Just spend some time to study it and if you have any concerns please ask specific question.

BTW @greensock
TweenLite is awesome :cool:

grammer
11-07-2009, 09:16 AM
thanks people. anymore ?

quiden
01-22-2010, 03:45 AM
import fl.transitions.Tween;
import fl.transitions.easing.*;

var homemanTween:Tween = new Tween(homeman_mc, "x", Elastic.easeOut, 1000, 50, 3, true);//frist tween


var adobeTween:Tween = new Tween(adobe_mc, "alpha", Regular.easeOut, 0, 1, 3, true);//second tween

Hey people how can I animate the 2nd tween after 3 seconds when 1st tween stops.

Thanks


Did you ever get an answer to this? This is something that I just recently figured out so I thought I'd share my solution with you.


//This is the first tween that you want to play
var firstTween:Tween = new Tween(mc,"alpha",Regular.easeOut,0,1,1,true);
//add event listener to tween which calls a function to run the second tween once it detects the the motion has finished
firstTween.addEventListener(TweenEvent.MOTION_FINI SH, step2)
//this is the function for the second tween
function step2(e:TweenEvent):void {
//here is the code for the second tween
var secondTween:Tween = new Tween(mc"alpha",regular.easeOut,1,0,1,true);
}


I'd be happy to hear feedback from anyone more experienced than I am as to whether this is a good way to do it, but it seems to be working well for what I want it to do, I thought it might help you too.