TweenLite

Some useful techniques when using TweenLite AS3 (a GREAT animation engine) in your AS3 projects.

  1. Uncomment the getter and setter at the bottom of the class source. This activates these methods:
public function get progress():Number
{
    return ((getTimer() - this.startTime) / 1000) / this.duration || 0;
}

public function set progress($n:Number):void
{
    var tmr:int = getTimer();
    var t:Number = tmr - ((this.duration * $n) * 1000);
    this.initTime = t - (this.delay * 1000);
    var s:Boolean = this.active; //Just to trigger all the onStart stuff.
    this.startTime = t;
    render(tmr);
}

You can then do something like
var myTween = TweenLite.to( obj, time, {objProps} );
// then later on...
trace (myTween.progress);

This almost works like a .isTweening property of other engines and is quite handy. You could always use an onUpdate I suppose, but that gets called a lot during tweening and thus wouldn't be as efficient in my opinion.
page_revision: 2, last_edited: 1204212725|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License