Tim Walling

technology is good

mx.transitions.Tween extended

13 comments

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:

Get Adobe Flash player

 

TweenDelay:

Get Adobe Flash player

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);

new TweenDelay(box3_mc, "_x", Regular.easeOut, box3_mc._x, 320, 2, .5, true);

The above line would move box3_mc along the x-axis to 320. It would take 2 seconds, but wouldn’t start for half a second.

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.

Written by Tim

June 22nd, 2005 at 12:42 am

Posted in Actionscript, Flash

13 Responses to 'mx.transitions.Tween extended'

Subscribe to comments with RSS or TrackBack to 'mx.transitions.Tween extended'.

  1. why dont you release this as an MXP ?

    pete

    11 Jan 06 at 2:48 am

  2. What advantages does it have as an MXP really? I prefer to just distribute the source code for any classes I happen to release.

    Tim

    11 Jan 06 at 10:18 am

  3. from the title of your post I thought you were talking about the TweenExtended class here: http://www.sqcircle.com/downloads/

    flashape

    11 Jan 06 at 11:01 am

  4. Sorry for the confusion. I first wrote this post back in the summer before I was aware of that class.

    Tim

    11 Jan 06 at 11:04 am

  5. Finally I find the solution with the extended Tween to load entire interface using only AS, extended tweens are awesome !
    Thanks.

    Stéphane Poison

    2 Apr 06 at 7:41 am

  6. Hey Tim, I like the TweenDelay class… what if I would like to stop the delay in progress, would I need to do a clearInterval(tweenObj.delay) ?

    You could probably overwrite the Tween.stop method do clear the interval and then run super.stop();

    What do you think?

    Danro

    15 Aug 06 at 3:39 pm

  7. Good point. I’ll update and post an new version.

    Tim

    15 Aug 06 at 3:48 pm

  8. I’m trying to get this to work on _alpha. In particular I’d like to delay an alpha from 0 to 100. but I can’t get it to work, anyone have any ideas?

    Thanks in advance.

    Adam

    29 Feb 08 at 12:22 pm

  9. I just tried the above example using _alpha instead and it worked fine.

    Tim

    4 May 08 at 9:17 pm

  10. I used for scaling. It works! Thanks!

    yuki

    8 Aug 08 at 9:42 am

  11. [...] the start of a tween. A while back I took my own shot at this based off of another class that I found and came up with: import mx.transitions.Tween; class com.vfd.animation.tweens.DelayedTween extends [...]

  12. hi theres, just to say that works like a charm….

    only have one question, i wanna make the property _visible start after x seconds or after for example a tweendelay of _alpha, for example:

    new TweenDelay(_root.contact, “_alpha”, Regular.easeOut, 100, 0, 1, 0, true);

    after the alpha reach 0 i want the _root.contact be _visible = true.

    any idea?

    thx in advance.

    Dave

    6 Nov 08 at 6:47 pm

  13. I realize this is a really old script, but it worked like a charm on an old website I had to update. I also got _alpha to work fine — I’m guessing your linkage wasn’t correct.

    Thanks for the script!

    Marcy Sutton

    21 Jan 09 at 1:24 pm

Leave a Reply