Tweenlite/Max is easily my favorite AS3/AS2 Tween Engine. Here’s a quick code snippet that most people do not know about!! If you enjoy using timers in AS3 check out the “delayedCall()” function in TweenMax/Lite. The key argument here is scalability, after a while using 1 line of codeĀ (delayedCall) becomes a lot more convenient then the more involved timer class.
Std. Timer listener dispatch + function
package {
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.Sprite;
public class TimerExample extends Sprite {
public function TimerExample() {
var myTimer:Timer = new Timer(1000, 2);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
}
public function timerHandler(event:TimerEvent):void {
trace("timerHandler: " + event);
}
}
}
VS.
Std. Tweenlite/Max delayedCall (v.11)
package {
import com.greensock.*;
import flash.display.Sprite;
public class DelayedCallExample extends Sprite {
public function DelayedCallExample() {
TweenLite.delayedCall(0.5, myDelayedCall, [1,true]);
}
public function myDelayedCall(argument1:Number,Boolean):void {
trace("that was easy!");
}
}
}
myD

