CustomAnimation

Example
var a = new CustomAnimation(1, bgFadeUpdate);

a.duration = 700; a.startValue = myText.bgOpacity; a.endValue = 100;

animator.start(a);

function bgFadeUpdate { var now = animator.milliseconds; var t = Math.max(0, now - this.startTime); var pct = t / this.duration; if (pct >= 1.0) { myText.bgOpacity = this.endValue; return false; } else { myText.bgOpacity = animator.ease(this.startValue,                                    this.endValue,                                     pct, animator.kEaseInOut); return true; } }

Notice that the function bgFadeUpdate uses this.startTime even though it was never defined. Don't worry, it is set when the animation is started.

We can also make our own generic Animations

HeightAnimation
function HeightAnimation(object,toHeight,duration,easeType,doneFunc){ var UpdateMe = function { var t      = animator.milliseconds - this.startTime; var percent = t / this.duration; if (percent >= 1) { this.object.height = this.toHeight; return false; }   this.object.height = animator.ease(this.startHeight,this.toHeight,percent,this.easeType); return true; } var a = new CustomAnimation(1,UpdateMe,doneFunc); a.object     = object; a.startHeight = object.height; a.toHeight   = toHeight; a.duration   = duration; a.easeType   = easeType;

return a; }