March 31st, 2005

Extending mx.transitions.Tween

This is a really cool AS 2.0 class for extending the mx.transitions.Tween class to pass multiple properties. I wish I had know about this before. I just finished up a small project where I was doing multiple lines of mx.transistions.Tween when I didn't need to be.

Here is some sample code on using the mx.transitions.TweenExtended once you installed it. This sample is moving the movieClip, ball_mc, to the position of 700x400 and also modifying its _alpha property. All in one line of code. Nice!!!

Actionscript:

  1. // import the Class
  2. import mx.transitions.TweenExtended;
  3. // I like defining the easingType as a variable, but it could be directly in the new TweenExtended line
  4. easingType = mx.transitions.easing.Back.easeOut;
  5. extendTween = new TweenExtended(ball_mc,["_x","_y","_alpha"],easingType,[ball_mc._x,ball_mc._y,ball_mc._alpha],[700,400,25],2,true);

The file is available for download from Square Circle Solutions [ link ]. Check the page out because there is some other cool stuff there as well.

(original story via FlashGuru)
One of the main features that the Macromedia Tween Class is lacking, is the ability to tween multiple properties of a movieclip using one instance of the tween class. My friend George has released a TweenExtended class that extends the Macromedia mx.transitions.Tween code allowing you to tween multiple properties with one instance of the class and alot less code.

You can download the class and many more goodies at our website:

http://www.sqcircle.com/downloads/

Comments are closed.