TweenNano is a super-lightweight (1.6k in AS3 and 2k in AS2) version of TweenLite and is ideal for situations where you cannot afford the extra 3.1k (4.7k total) that the normal TweenLite engine would cost and your project doesn’t require any plugins. TweenNano can do everything TweenLite can do with some exceptions.
For a measly 1.6k, TweenNano is surprisingly capable. It can tween as many properties as you want of any object, base timing on frames or seconds, use onComplete
and onUpdate
callbacks, make delayedCall()
s, do from()
tweens, kill all the tweens of a particular object, and TweenNano easily outperforms most other engines including Adobe’s Tween class (by a wide margin).
Sample
import com.greensock.*; //create the timeline and add an onComplete callback that will call myFunction() when the timeline completes var myTimeline:TimelineLite = new TimelineLite({onComplete:myFunction}); //add a tween myTimeline.append(new TweenLite(mc, 1, {x:200, y:100})); //add another tween at the end of the timeline (makes sequencing easy) myTimeline.append(new TweenLite(mc, 0.5, {alpha:0})); //reverse anytime myTimeline.reverse(); //Add a "spin" label 3-seconds into the timeline myTimeline.addLabel("spin", 3); //insert a rotation tween at the "spin" label (you could also define the insert point as the time instead of a label) myTimeline.insert(new TweenLite(mc, 2, {rotation:"360"}), "spin"); //go to the "spin" label and play the timeline from there myTimeline.gotoAndPlay("spin"); //add a tween to the beginning of the timeline, pushing all the other existing tweens back in time myTimeline.prepend(new TweenMax(mc, 1, {tint:0xFF0000})); //nest another TimelineLite inside your timeline... var nestedTimeline:TimelineLite = new TimelineLite(); nestedTimeline.append(new TweenLite(mc2, 1, {x:200})); myTimeline.append(nestedTimeline);