A few months ago I had released an easing tween class that I wrote in AS2 based on the easing formula posts. The basic principle is to get a clip to move, scale or rotate from point A to B with different movement equations. this is an alternative class similar to the fuse kit, the Robert Penner equations, the Zeh Fernando MC tween, the Zigo/Laco or the tween classes found in Flash. Here is the principle
import com.reflektions.tween.*;
var tween:Tween = new Tween();
var tobj:Object = {mc:mc,x:x,dx:dx}; //x init and dx final position
tween.initTween(tobj);
I rewrote the class in AS3 and you can download it here. I also added custom event dispatchers that dispatch events when the clip is animating and when tween completed. The movieclip reference and time (0 to 1) are also passed through the custom event.
// Add Listener to tween events
tween.addEventListener(TweenEventDispatcher.TWEEN_PROGRESS, progressListener);
tween.addEventListener(TweenEventDispatcher.TWEEN_COMPLETE, completeListener);
n.b: as far as passing properties go you can pass (x:,dx:) for x tweening, (y:,dy:) for y tweening, (r:,dr:) for rotation, (a:,da:) for transparency and (xscale:,dxscale:) and (y:,dyscale:) for scaling on both axis. Enjoy, here is an examples that tweens 5 different clips with different equations at different speeds.
import com.reflektions.tween.*;// import com.reflektions.tween.equations.*;//
function initAnimation():void {
// define properties
var mc:MovieClip = follow_mc_1;// clip to tween
var x:Number = mc.x;
var dx:Number = (x == point_1.x) ? point_0.x : point_1.x;//switch target accordfing to position
var tween:Tween = new Tween();
var tobj:Object = {mc:mc,x:x,dx:dx};
tween.initTween(tobj,Shubring.easeInOut,10); // or pass extra parameters sucha as equation and speed
// Add Listener to tween events
tween.addEventListener(TweenEventDispatcher.TWEEN_PROGRESS, tweenProgressListener);
tween.addEventListener(TweenEventDispatcher.TWEEN_COMPLETE, tweenCompleteListener);
}
// Check Complete
function tweenCompleteListener(e:TweenEventDispatcher):void {
// Accordig to completed reset animation
if (e.params.target.name == "follow_mc_1") { // check to see if target is clip we animated (optional)
initAnimation();
}
}
// Check progress
function tweenProgressListener(e:TweenEventDispatcher):void {
trace(["progress... ",e.params.target,e.params.time])
}
// Initiate
initAnimation();