I've tried out various animation/tweening packages and one of the features I really liked with one or two was the ability to put in a delay before the tween. Many times I'll list out several tweens, one after another, but I'd like to stagger them. Not sure how other people handle it but I like when its built into whatever tweening package I'm using.
Recently I switched to using Macromedia's Tween class since the one I was using at the time seemed to be unstable. I converted all the tweens over to mx.transitions.Tween and everything has been working much better ever since.
My only complaint? There's no delay parameter to pass with a new tween. My solution? I played around with extending the class and ended up with TweenDelay. The only new param is "delay" which will cause the tween to wait before executing. I thought about wrapping the Tween class in my own class, but then I'd have to expose all the API's to the Tween class so I went this route.
Here are two examples, one using Tween, the other using TweenDelay:
Tween:
TweenDelay:
You can use TweenDelay the same way you use Tween. There's just a new param to pass in. Set it to zero if you don't want a delay.
new TweenDelay(obj, prop, func, begin, finish, duration, delay, useSeconds);
The following line would move box3_mc along the x-axis to 320. It would take 2 seconds, but wouldn't start for half a second.
new TweenDelay(box3_mc, "_x", Regular.easeOut, box3_mc._x, 320, 2, .5, true);
There's a good intro to using Macromedia's tweening classes here:
http://www.macromedia.com/devnet/mx/flash/articles/tweening.html
You can download TweenDelay here.
There's a sample fla included. Please feel free to give me any feedback, especially bugs. This was my first time extending a Macromedia class.