Tweening the Gap

I’ve been doing a lot of projects using a Flash add-on called TweenLite recently, and let me tell you, it helps tremendously. TweenLite is a plugin by GreenSock that takes the basic Flash tweener functions and simplifies them to make coding the animation of objects way easier. I’ll give you an example;

If we were using Flash’s default Tween class, your code would look like this…

//==========================================

import mx.transitions.Tween;
import mx.transitions.easing.*;
var xScaleT:Tween = new Tween(kText, “_rotation”, Elastic.easeOut, 0, 360, 3, true);
var xPosT:Tween = new Tween(kText, “_x”, Bounce.easeOut, 0, Stage.width, 3, true);
xScaleT.onMotionFinished = function() {
this.yoyo();
};
 
//==========================================
 
Now, that’s all well and good, and will work in a pinch, but using TweenLite (which, did I mention, is totally free?) you can consolidate that to the following…
 
//==========================================
 
import gs.TweenLite;
 
TweenLite.To(kText, 3, {_rotation:360, _x:stage._width, ease:Elastic.easeOut, onComplete:this.yoyo, overwrite:false});
 
//==========================================
 
Way easier, no? The cool thing about it is that you can plug in as many different tweens  as you want into one line of code, so you can adjust alpha, position, scale, color, or anything else all at the same time! This keeps code neat and makes searching for your tweens way easier. Plus, it barely takes up any space in your file. All you need to do is put some small folders containing the TweenLite files in your flash directory with the .swf files, and you’re good to go!