Mandatory ActionScript library for animation - MC Tween
Have you ever had to write a piece of code to resize or move a MovieClip on the stage dynamically, using onEnterFrames or other dirty methods? If so, you should take a look at MC Tween. MC Tween is a free set of ActionScript prototypes (those little bits of code that extend already existent objects like MovieClips) written by Zeh Fernando. It offers a clean alternative to any home built code: All animations are time – not frame – based, which means a MC Tween controlled animation will run just as long on a slow computer as on a fast computer, since the speed of the animation is synchronized to the computer's internal clock, not the frame rate of the player. In addition MC Tween uses its own objects to assign onEnterFrames to, so the event handler of the object to be transformed remains free for your own behaviors.
Using MC Tween is a cakewalk. Download and install the Flash extension, add one line of code to your stage and your good to go. The extension even adds code helpers to the Action window in Flash.
You can download the latest version from http://hosted.zeh.com.br/mctween/downloads.html. After that add the following line of code to the first frame on your stage.
#include "mc_tween2.as"
The package will add a few kilo bytes to your SWF size and increase the compile time by a few seconds, but it’s well worth it.
Let’s look at a simple example, moving a MovieClip across the stage. To move the MovieClip from along the x-axis I use the xSlideTo command. All I need to start the tween is the following line:
box_mc.xSlideTo(250,2);
250 is the new x value, 2 is the time in seconds for the tween to complete. The default animation type is exponential easing out, but there are plenty of other animation types available, all based on Robert Penner’s work. Switching to another animation type is easy, just add the name of the animation type to the tween command:
box_mc.xSlideTo(190,2,"easeOutElastic");
It is also possible to add a delay before the animation starts and add a callback function after the animation finishes, which is great for stacking animations. All in all MC Tween allows you to tween MovieClips, Sounds and Textfields, and modify attributes such as position, size, rotation, alpha, volume, pan, scroll position, as well as the Flash 8 filters bevel, blur, and glow. This prototype package is so complete, I find use for it in almost every project.
Adobe announces Flash CS5!
There are no comments for this entry.
[Add Comment]