TweenNano – 1.6k TweenLite with Some Sacrifices
- Version: 1.05, Updated 2010-05-11
- File size added to compressed SWF: About 1.6kb (AS3), or 2kb (AS2)
Description
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 the following exceptions:
- No Plugins - One of the great things about TweenLite is that you can activate plugins in order to add features (like autoAlpha, tint, blurFilter, etc.). TweenNano, however, doesn't work with plugins.
- Incompatible with TimelineLite and TimelineMax - Complex sequencing and management of groups of tweens can be much easier with TimelineLite and TimelineMax, but TweenNano instances cannot be inserted into TimelineLite or TimelineMax instances. Sequencing in TweenNano can be done using the "delay" special property.
- Fewer overwrite modes - You can either overwrite all or none of the existing tweens of the same object (overwrite:true or overwrite:false) in TweenNano. TweenLite, however, can use OverwriteManager to expand its capabilities and use modes like AUTO, CONCURRENT, PREEXISTING, and ALL_ONSTART (see http://www.greensock.com/overwritemanager/ for details).
- Compared to TweenLite, TweenNano is missing the following methods/properties: pause(), play(), resume(), restart(), reverse(), invalidate(), onStart, defaultEase, easeParams, currentTime, startTime, totalTime, paused, reversed, and totalDuration. See the feature comparison chart for details about how TweenNano, TweenLite, and TweenMax compare.
TweenNano uses exactly the same syntax as TweenLite, so all the documentation and examples for TweenLite apply to TweenNano as well (except for the features mentioned above of course).
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).
Getting started
If you're new to the GreenSock Tweening Platform, check out the "getting started" page. You'll be up and running in no time.
Documentation
Please see the full ASDoc documentation.
Sample AS3 code
(AS2 is identical except for property names like "x", "y", and "alpha" are "_x", "_y", "_alpha" and alpha would be 100-based instead of 1-based).
-
import com.greensock.*;
-
import com.greensock.easing.*;
-
-
//tweens mc's alpha property to 0.5 and x property to 120 from wherever they are currently over the course of 1.5 seconds.
-
TweenNano.to(mc, 1.5, {alpha:0.5, x:120});
-
-
//same tween, but uses the Back.easeOut ease, delays the start time by 2 seconds, and calls the "onFinishTween" function when it completes, passing two parameters to it, 5 and "myParam2".
-
TweenNano.to(mc, 1.5, {alpha:0.5, x:120, ease:Back.easeOut, delay:2, onComplete:onFinishTween, onCompleteParams:[5, "myParam2"]});
-
-
//tweens mc into place from 100 pixels above wherever it currently is, over the course of 1 second using the Elastic.easeOut ease.
-
TweenNano.from(mc, 1, {y:"-100", ease:Elastic.easeOut});
FAQ
- Do you plan on eventually making TweenNano compatible with plugins?
No. I am not interested in blurring the line between TweenNano and TweenLite by adding plugin capability or other features to TweenNano. The sole purpose of TweenNano is to provide an extremely lightweight engine capable of doing basic tweening, nothing more. If you want plugin-like capabilities, you can always use TweenNano's onUpdate callback to have your own function perform any action every time the tween values are updated. - I thought TweenLite was already lightweight. Why create TweenNano if it only saves 3.1k?
Believe it or not, some developers (mostly banner ad creators) will rejoice at the thought of getting an extra 3.1k because they are forced to work within extremely tight file size constraints. That being said, if you're trying to decide whether you should use TweenNano or TweenLite, I'd recommend using TweenLite and only shifting to using TweenNano if that 3.1k becomes critical. TweenLite is definitely more flexible with its plugins and compatibility with TimelineLite and TimelineMax. - How do I install the class? Do I have to import it on every frame?
Please refer to the "getting started" page. - Why do my tweens keep getting overwritten? How can I prevent that?
By default, when you create a tween, TweenNano looks for all existing tweens of the same object and kills them immediately. However, you can prevent this behavior by using overwrite:false in your vars object, like TweenNano.to(mc, 1, {x:100, overwrite:false}); - Can I set up a sequence of tweens so that they occur one after the other?
Sure. Just use the "delay" special property, like :Actionscript:-
import com.greensock.TweenNano;
-
TweenNano.to(mc, 2, {x:100});
-
TweenNano.to(mc, 1, {y:300, delay:2, overwrite:false});
-
- Do the properties have to be in a specific order?
Nope. The only thing that matters is that the first parameter is the object you're tweening, the second parameter is the time (in seconds), and the third parameter contains all the properties you want to tween (in any order). So TweenNano.to(mc, 1, {scaleX:1.2, y:200, x:1}) is the same as TweenNano.to(mc, 1, {x:1, y:200, scaleX:1.2}); - Do I have to purchase a license to use this code? Can I use it for commercial purposes?
You may use the code at no charge in commercial or non-commercial web sites, games, components, applications, and other software as long as end users are not charged a fee of any kind to use your product or gain access to it. If your client pays you a one-time fee to create the site/product, that's perfectly fine and qualifies under the "no charge" license. If multiple end users are charged a usage/access/license fee of any kind, please simply sign up for a corporate Club GreenSock membership which comes with a special commercial license granting you permission to do so. Club GreenSock members get several useful bonus plugins, classes, update notifications, SVN access, and more. Your support keeps this project going. Please see the licensing page for details on licensing.
Need help?
Feel free to post your question on the forums. You'll increase your chances of getting a prompt answer if you provide a brief explanation and include a simplified FLA file (and any class files) that clearly demonstrates the problem.
Comments (12)

Wow Jack! we love TweenNano!
Will use it in every banner from now on…
Totally onboard with this release. Is great news. 3.1k can be all you need when you are developing a banner. Thanks again for creating an amazing product one more time.
This is awesome, great and excellent all at the same time!
dude, about time! thanks for this. being a banner ad creator, an extra 3.1k can be like saving 1Gb. You truly are a king among men. Thanks a bunch.
Wow this is amazingly awesome. thanks for thinking about Ad & banner creators. TweenNano 100% GOOD and it uses the same syntax as TweenLite..
Bless Green Man, you rock…..
Rejoice! TweenNano just saved me from doing 25-life.
Thx Jack,
you managed to remove every last rest of possible reasons to not use your api in certain cases. I dont often make banners, but when i do, im thankful for every last kb.
Dude!!! Stop beating up Nano!! It’s pg reads like a “Why You Should Hate This!” It’s a 1.6′er and I work in advertising, so sometimes having this in a 40k environment freakin’ rox!
Be proud on the tools. Your eases are slicker than Penner’s and Flash’s combined AND those SICK code generating tools are amazing!!! Proud to use your stuff and hoping for a seminar or for SFSU to maybe recognize how often this is used and teach a class.
Seriously, I bounce from agency to agency around SF and EVRYONE knows and raves about TweenMax. I’m at Teak Motion Visuals on a gig and it was just assumed I knew TweenMax. LOVE IT! AS3 and TweenMax are the tools to know for todays pros!! Thanks, for the tiny solution!!!
And, Keep on crankin!!!!!! I can’t wait to see what I get to do next!
J
You make my Year with Nano…thanks!
Oh wow this is good news!
Making banner ads suck a** but TweenNano eases the job a little bit. Actually, right now, I couldn’t get my work done without TweenNano. Thanks Jack!
This rocks! Thanks!
Forever a fan of TweenMax, you, TweenNano have just saved my life. <3 Brightening up even the lowliest banner ads. THX!!









