* Below is the fastest AS3 tweening engine.

Bold statement? Probably – but I’ve experimented with this basic idea since 2003 and have literally hundred of variants. This is the fastest thing I’ve come up with.

It’s totally bare-bones. There are no utility methods whatsoever. Notice it extends EventDispatcher but doesn’t have any event management built in. That’s on purpose – this is to serve as a base only – it can be extended (not suggested) or (more realistically) used as a template and written to accommodate your specific needs. I’ve used it for color tween, bezier tweens, with pre-fab easing functions (optimized versions of Penners – as an aside, that’s one way to dramatically improve the performancy of any tween, and usable with almost all publicly available engines).

If you just wanted an event to fire on complete, you’d just dispatch an event right after delete list[reference]. If you wanted to get back progress every frame, you dispatch an event right before/after the property assignment line. You could create a static method that reset the dictionary (list = new Dictionary()) that’d clear all currently executing tweens. You get the idea.

Just a note – a version of this I use, with tons of utility methods and event dispatches during start, progress (every frame!) and finish still outperforms all other public Tweening engines, including TweenLite and Tweensy, by at least 20%.

* That is not to say this is the best tweening engine – far from it – and I’ll restate that, as written, it doesn’t do much… It’s posted as a demonstrative example, and not something that’s meant for public consumption. I’ve had a few people contact me about adapting it for use for a particular project – while you’re free to do that, please note that this is an exercise, not a ready-to-wear plugin. Thanks!

package {

import flash.display.Shape;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.utils.Dictionary;

public class BaseTween extends EventDispatcher{

protected static var list:Dictionary = new Dictionary();
protected static var initted:Boolean = false;
protected static var engine:Shape = new Shape();

protected static function exec(event:Event):void{
var working:Boolean = false;
var key:Function;
for each(key in list){
working = true;
engine.removeEventListener(Event.ENTER_FRAME, exec);
initted = false;

public function BaseTween(target:Object, steps:int, ease:Function, props:Object, overwrite:Boolean = true):void{

engine.addEventListener(Event.ENTER_FRAME, exec, false, 0, true);
initted = true;

var reference = overwrite ? target : { };
var loop:uint = 0;
var factor:Number;
var prop:String;
var old:Object = { };

for (prop in props) {
old[prop] = target[prop];

list[reference] = function():void{
factor = ease(++loop, 0, 1, steps);
for (prop in props) {
target[prop] = old[prop] + (props[prop] – old[prop]) * factor;
if(loop == steps){
delete list[reference];