TweenMax – TweenLite on Steroids
- Version: 11.2, Updated 2010-03-06
- File size added to compressed SWF: About 8.7kb (base), or 17.6kb with default plugins and OverwriteManager
What's new in v11?
v11 represents the biggest update to the platform ever, by far. Please check out the official announcement page for details about the changes and new features.
Description
TweenMax extends the extremely lightweight, fast TweenLite engine, adding many useful features like timeScale, AS3 event dispatching, updateTo(), yoyo, repeat, repeatDelay, rounding, and more. It also activates many extra plugins by default, making it extremely full-featured. Since TweenMax extends TweenLite, it can do anything TweenLite can do plus much more. The syntax is identical. With plenty of other tweening engines to choose from, here's why you might want to consider TweenMax:
- SPEED - TweenMax has been highly optimized for maximum performance. See some speed comparisons here.
- Feature set - In addition to tweening any numeric property of any object, TweenMax can tween filters, hex colors, volume, tint, frames, saturation, contrast, hue, colorization, brightness, and even do bezier tweening, orientToBezier, round values, jump to any point in the tween with the currentTime or currentProgress property, automatically rotate in the shortest direction, plus LOTS more. Overwrite management is an important consideration for a tweening engine as well which is another area where the GreenSock Tweening Platform shines. You have options for AUTO overwriting or you can manually define how each tween will handle overlapping tweens of the same object.
- Expandability - With its plugin architecture, you can activate as many (or as few) features as your project requires. Write your own plugin to handle particular special properties in custom ways. Minimize bloat, and maximize performance.
- Sequencing, grouping, and management features - TimelineLite and TimelineMax make it surprisingly simple to create complex sequences or groups of tweens that you can control as a whole. play(), pause(), restart(), or reverse(). You can even tween a timeline's currentTime or currentProgress property to fastforward or rewind the entire timeline. Add labels, gotoAndPlay(), change the timeline's timeScale, nest timelines within timelines, and lots more.
- Ease of use - Designers and Developers alike rave about how intuitive the platform is.
- Updates - Frequent updates and feature additions make the GreenSock Tweening Platform reliable and robust.
- AS2 and AS3 - Most other engines are only developed for AS2 or AS3 but not both.
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 view full ASDoc documentation here. For your convenience, the special properties are listed below as well, but to read up on all the methods and properties, definitely check the ASDocs.
Interactive demo - tweening basics
Special properties
You can pass any of the following special properties in through the constructor's "vars" parameter like new TweenMax(mc, 1, {x:100, delay:1.5, paused:true, onComplete:myFunction}) to control various aspects of the tween:
- delay : Number - Number of seconds (or frames if useFrames is true) that should elapse before the tween begins.
- paused : Boolean - Sets the initial paused state of the timeline (by default, tweens automatically begin playing)
- useFrames : Boolean - If useFrames is set to true, the tween's timing mode will be based on frames. Otherwise, it will be based on seconds/time. NOTE: a tween's timing mode is always determined by its parent timeline.
- ease : FunctionUse any standard easing equation to control the rate of change. For example, Elastic.easeOut. The Default is Quad.easeOut.
- easeParams : Array An Array of extra parameters to feed the easing equation (beyond the standard first 4). This can be useful when using an ease like Elastic and want to control extra parameters like the amplitude and period. Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams.
- reversed : Boolean - If true, the tween will be reversed initially. This does not swap the starting/ending values in the tween - it literally changes its orientation/direction. Imagine the playhead moving backwards instead of forwards. This does NOT force it to the very end and start playing backwards. It simply affects the orientation of the tween, so if reversed is set to true initially, it will appear not to begin because it is already at the beginning. To cause it to play backwards from the end, set reversed to true and then set the currentProgress property to 1 immediately after creating the tween (or set the currentTime to the duration).
- immediateRender : Boolean Normally when you create a tween, it begins rendering on the very next frame (when the Flash Player dispatches an ENTER_FRAME event) unless you specify a delay. This allows you to insert tweens into timelines and perform other actions that may affect its timing. However, if you prefer to force the tween to render immediately when it is created, set immediateRender to true. Or to prevent a tween with a duration of zero from rendering immediately, set this to false.
- overwrite : int Controls how (and if) other tweens of the same target are overwritten by this tween. There are several modes to choose from, and TweenMax automatically calls OverwriteManager.init() if you haven't already manually dones so, which means that by default AUTO mode is used (please see http://www.greensock.com/overwritemanager/ for details and a full explanation of the various modes):
- NONE (0) (or false)
- ALL_IMMEDIATE (1) (or true)
- AUTO (2) - this is the default mode for TweenMax.
- CONCURRENT (3)
- ALL_ONSTART (4)
- PREEXISTING (5)
Example: TweenMax.to(mc, 1, {x:100, overwrite:5});
- repeat : int - Number of times that the tween should repeat. To repeat indefinitely, use -1.
- repeatDelay : Number - Amount of time in seconds (or frames for frames-based tweens) between repeats.
- yoyo : Boolean - Works in conjunction with the repeat property, determining the behavior of each cycle. When yoyo is true, the tween will go back and forth, appearing to reverse every other cycle (this has no affect on the "reversed" property though). So if repeat is 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. But if repeat is 2 and yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end.
- startAt : Object Allows you to define the starting values for each property. Typically, TweenMax uses the current value (whatever it happens to be at the time the tween begins) as the start value, but startAt allows you to override that behavior. Simply pass an object in with whatever properties you'd like to set just before the tween begins. For example, if mc.x is currently 100, and you'd like to tween it from 0 to 500, do TweenMax.to(mc, 2, {x:500, startAt:{x:0}});
- onInit : Function - A function that should be called just before the tween inits (renders for the first time). Since onInit runs before the start/end values are recorded internally, it is a good place to run code that affects the target's initial position or other tween-related properties. onStart, by contrast, runs AFTER the tween inits and the start/end values are recorded internally. onStart is called every time the tween begins which can happen more than once if the tween is restarted multiple times.
- onInitParams : Array - An Array of parameters to pass the onInit function.
- onStart : Function - A function that should be called when the tween begins (when its currentTime is at 0 and changes to some other value which can happen more than once if the tween is restarted multiple times).
- onStartParams : Array - An Array of parameters to pass the onStart function.
- onUpdate : Function A function that should be called every time the tween's time/position is updated (on every frame while the tween is active)
- onUpdateParams : Array - An Array of parameters to pass the onUpdate function
- onRepeat : Function - A function that should be called every time the tween repeats
- onRepeatParams : Array - An Array of parameters to pass the onRepeat function
- onComplete : Function - A function that should be called when the tween has completed. To sense when a tween has reached its starting point again after having been reversed, use onReverseComplete.
- onCompleteParams : Array - An Array of parameters to pass the onComplete function
- onReverseComplete : Function - A function that should be called when the tween has reached its starting point again after having been reversed
- onReverseCompleteParams : Array - An Array of parameters to pass the onReverseComplete function
- onStartListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent when it begins. This is the same as doing myTween.addEventListener(TweenEvent.START, myFunction);
- onUpdateListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent every time it updates values. This is the same as doing myTween.addEventListener(TweenEvent.UPDATE, myFunction);
- onCompleteListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent when it completes. This is the same as doing myTween.addEventListener(TweenEvent.COMPLETE, myFunction);
- onReverseCompleteListener : Function A function to which the TweenMax instance should dispatch a TweenEvent when it completes in the reverse direction. This is the same as doing myTween.addEventListener(TweenEvent.REVERSE_COMPLETE, myFunction);
- onRepeatListener : Function A function to which the TweenMax instance should dispatch a TweenEvent when it repeats. This is the same as doing myTween.addEventListener(TweenEvent.REPEAT, myFunction);
Plugins
Plugins allow you to expand the capabilities of TweenLite/Max by handling specific properties in unique ways. Each plugin is associated with a special property name and it takes responsibility for handling that property. For example, the FrameLabelPlugin is associated with the "frameLabel" special property so if it is activated it will intercept the "frameLabel" property in the following tween and manage it uniquely:
-
TweenMax.to(mc, 1, {frameLabel:"myLabel"});
If the FrameLabelPlugin wasn't activated, TweenMax would act as though you were trying to literally tween the mc.frameLabel property (and there is no such thing).
Activating a plugin requires a single line of code and you only need to do it ONCE in your application, so it's pretty easy. Simply pass an Array containing the names of all the plugins you'd like to activate to the TweenPlugin.activate() method, like this:
-
TweenPlugin.activate([FrameLabelPlugin, ColorTransformPlugin]);
To make it even easier, I created the Plugin Explorer which writes the code for you. All you need to do is select the plugins and copy/paste the code from the bottom of the tool. It also shows interactive examples of each plugin and the assocaited code so that it's easy to see the correct syntax.
TweenMax automatically activates many plugins by default, but you can change which plugins it activates by opening the class file and commenting or uncommenting the necessary lines towards the top of the class (clearly labeled).
Sample code
NOTE: All sample code is in AS3, but the AS2 version works exactly the same except the property names may be different, like "_x" instead of "x", "_alpha" instead of "alpha", etc. And in AS3, alpha/scaleX/scaleY go from 0-1 whereas in AS2, _alpha/_xscale/_yscale go from 0-100. This has nothing to do with TweenLite/Max - it's just a change Adobe made in the AS3 language.
-
//import the GreenSock classes
-
import com.greensock.*;
-
import com.greensock.easing.*;
-
-
//tween the MovieClip named "mc" to an alpha of 0.5 over the course of 3 seconds
-
TweenMax.to(mc, 3, {alpha:0.5});
-
-
//scale myButton to 150% (scaleX/scaleY of 1.5) using the Elastic.easeOut ease for 2 seconds
-
TweenMax.to(myButton, 2, {scaleX:1.5, scaleY:1.5, ease:Elastic.easeOut});
-
-
//tween mc3 in FROM 100 pixels above wherever it is now, and an alpha of 0. (notice the vars object defines the starting values instead of the ending values)
-
TweenMax.from(mc3, 1, {y:"-100", alpha:0});
-
-
//tween mc4 from x:100 to x:300 while changing its tint from whatever it is when the tween starts to red (0xFF0000)
-
TweenMax.fromTo(mc4, 1, {x:100}, {x:300, tint:0xFF0000});
-
-
//after a delay of 3 seconds, tween mc for 5 seconds, sliding it across the screen by changing its "x" property to 300, using the Back.easeOut ease to make it shoot past it and come back, and then call the onFinishTween() function, passing two parameters: 5 and mc
-
TweenMax.to(mc, 5, {delay:3, x:300, ease:Back.easeOut, onComplete:onFinishTween, onCompleteParams:[5, mc]});
-
function onFinishTween(param1:Number, param2:MovieClip):void {
-
trace("The tween has finished! param1 = " + param1 + ", and param2 = " + param2);
-
}
-
-
//call myFunction() after 2 seconds, passing 1 parameter: "myParam"
-
TweenMax.delayedCall(2, myFunction, ["myParam"]);
-
-
//tween every MovieClip in the "letters" Array up 100 pixels (changing their "y" property to a relative value of "-100") over 2 seconds while fading out, and stagger the start time of each tween by 0.1 seconds. There could literally be hundreds of MovieClips in the "letters" Array and this one line of code would tween them all!
-
TweenMax.allTo(letters, 2, {y:"-100", alpha:0}, 0.1);
-
-
//use the object-oriented syntax to create a TweenMax instance and store it so we can reverse, restart, or pause it later. Make it repeat twice with a 1-second delay between each repeat cycle.
-
var myTween:TweenMax = new TweenMax(mc2, 3, {y:200, repeat:2, repeatDelay:1, onComplete:myFunction});
-
-
//some time later (maybe in by a ROLL_OUT event handler for a button), reverse the tween, causing it to go backwards to its beginning from wherever it is now.
-
myTween.reverse();
-
-
//pause the tween
-
myTween.pause();
-
-
//restart the tween
-
myTween.restart();
-
-
//make the tween jump to its halfway point
-
myTween.currentProgress = 0.5;
FAQ
- Is the new version of TweenMax backwards compatible with v10?
The short answer is "yes, mostly", but I'd strongly encourage you to check out the official announcement page for details because a few things have changed. - I don't want to use v11 - can I get a legacy copy of v10?
Sure. But I do not plan to update previous versions. v10 was very stable and you can get it here: Download AS2 | Download AS3 - How do I activate extra plugins?
Check out the Plugin Explorer above. Not only does it provide interactive examples of each plugin, but it also writes the activation code for you and shows how many kb the plugins will cost. - How do I install the class? Do I have to import it on every frame?
Please refer to the "getting started" page. - Can I set up a sequence of tweens so that they occur one after the other?
Of course! That's precisely what TimelineLite and TimelineMax are for. But if file size is a big concern and you don't need all the fancy extras those tools offer, you could just use the delay property in TweenMax. Here's an example where we tint a MovieClip red over the course of 2 seconds, and then move it to a y coordinate of 300 over the course of 1 second:Actionscript:-
import com.greensock.TweenMax;
-
TweenMax.to(mc, 2, {tint:0xFF0000});
-
TweenMax.to(mc, 1, {y:300, delay:2});
-
- Do the properties have to be in a specific order?
Nope. So TweenMax.to(mc, 1, {x:100, y:200, alpha:0.5}) is the same as TweenMax.to(mc, 1, {alpha:0.5, y:200, x:100}); - Is there a way I can get code hinting and strict datatyping in the vars object I pass to TweenLite/TweenMax?
Sure, the TweenMaxVars class does exactly that. - 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. See http://www.greensock.com/club/ for details. Club GreenSock members get several nifty bonus plugins, classes, update notifications, SVN access, and more. Your donations keep 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 (54)

Thank you sooooooooo much!!!
That is simply “perfect”
I’m glad with this release! Thank you very much Jack!
pd: bezierThrough is pretty cool, great idea (I never like the bezier system)
Thanks! These classes are awesome! They have become an invaluable part of my AS3 coding arsenal . . . finding uses in almost every project on which I’m working. I made a donation today to support your work and encourage others to do the same.
Nice job Jack! Very impressive!
Unbelievable , great , beautiful work !!
Thank you Jack !! it is what we were waiting for !!
Absolutely brilliant, Jack.
Much thanks =)
Absolutely incredible. Thank you so much for all your releases. TweenLite especially has been magical, even in 3D.
i don’t know what to say…
this is just too good to be true.
thank u so much, jack!
This is really great. I really like the feature of tweening through beizer points.
Man…. you are THE MAN!
I love your work and as always… its very impressive…. I’ve been tweening with tweenlite like crazy…. but now… its MAX-crazy time!
keep up the great work…
by the way… I love combining your tween engine with my new hobby (Papervision3d)… they work awsome together.
Awsome! I was fiddling around, and guess what… bezier tweening is not just for position objects! you can bezier tween anything.
I agree with everyone else. TweenMax is the absolute greatest – now that it consolidates the other 2 engines, and still VERY small size. As a designer / flash developer, i highly recommend this to everyone! Thank you for all of your hard work. Keep it up!
I’d like to praise you for THE greateste piece of programming I’ve seen in ActionScript… Small, fast, reliable… What else?
Again, you rock brother — TweenMax is a God send and just in the nick-o-time especially with the BezierTo and OrientToBezier funcs — fantastic, I’m already use this on Pro Projects right now — and yes I will donate as soon as I can paid from the client
You deserve it, seriously.
ROCK ON! Ozzy
Very amazing tweening engine. I replaced it with the Adobe tween class in my current project, and well.. Tweens where smooth again
. I’m going to develop futher with it, hoping to find the perfect tween engine in this.
Keep on the good work!
Once again, you’ve made my life easier like you wouldn’t believe.
However, I’m holding out sending my firstborn child to you until I see this:
TweenUltraSuperMax3.buildWebsite(this, 0, {buttons, content, copy, onComplete:PayMe});
Thanks a ton!
I am speechless… I would like to just drop a line to commend you on a fantastic piece of code. Small fast and awesome …
Speechless and grinning like mad is all I have to say.
Bravo mister Doyle! TweenMax is THE most important package in my business’ framework!
Dude….
This is simply…
THE SHIZLNIT!!!! Wow your programming ingenuity is amazing!
Garlon sums up my thoughts exactly!
Thanks, really! The most useful piece AS3 programming of em all!
you are my Hero!!!! You just saved me at least a week of struggling…
People like you truly make the world go forward, not just around.
Thank you for your generosity
Wow. I mean, wow.
Nothing else compares – and I’m taking that out of the API scope; I mean MP3 players, baklava, and new girlfriends.
You’ve taken all the fun out of life…and that’s okay.
Just wanted to say thanks as well. Your willingness to share what you have put very hard work into is appreciated. Your Tween engines are by far the best I’ve come across. Keep up the great work and thanks again!
Hooray for yoyo! Thanks again for the constant barrage of updates to this excellent class.
Great work, I just got done banging my head against HydroTween and for me this was much easier to get what I needed to do done.
Thanks for TweenMax, you are an Actionscript hero!
Great work! I’ve been looking for something exactly like this for a long time. bezierThrough – it’s realy something. TweenMax.globalTimeScale – very interesting. Thanks a lot!
I’ve been making some great strides using Papervision3D with TweenMax. It is able to do all our tweening for Cameras & Objects and also Groups of Object using DisplayObject3D.
//create a new DisplayObject3D at the top
private var bigContainer:DisplayObject3D = new DisplayObject3D();
//add the bigContainer to the scene
default_scene.addChild(bigContainer);
//add some items to the DisplayObject3D
bigContainer.addChild(MOVIECLIP);
//spin it!
TweenMax.to(bigContainer, 10, {rotationY:360,loop:true,ease:Regular.easeInOut});
Tween a Scene within a Scene!
Fantastic work. This works so much better than the built-in tween handlers – and creating sweet effects is just a breeze.
I’m so happy I found you, GreenSock and Jack
Amazing work! I can’t imagine doing anything without your classes anymore…
WOW – roundProps! Another wonderful feature, this is awesome! Die half pixels, die
Go go roundProps! Tweens away!
this tool is PERFECT!
bravo and thank you VERY much!
little details like “autoAlpha” are so cool
A WEEK OF BANGING MY HEAD ON A DESK solved in 1 friggin day of work
and THANK YOU!
PS: Will be donating 4 sure
shortRotation is exactly that feature I have missed two weeks ago and I have been so frustrated because I needed about half the day to get the result I needed…
Thanks very much. Saved me from having to solve an issue with tweens not finishing because TweenMax works just as expected! Dropped it in and the problems went away.
You think you know, but you have no idea what you did to my work style with your amazing TweenMax class, and how happy and satisfied I am with your meritorious work – your classes become the base of all of my projects, I use it every ware instead of the timeline, all of the methods are very useful especially the from() and allFrom(), not only this, it is also available for both AS3 and AS2 which mean my current and old projects still supported with the latest updates..
I feel I have to donate, please accept a BIG Thank you from me.
OMG. This class is AMAZING. You really deserve my donation. Don’t know if it’s fair enough but I really have to.
Thanks!
Jack, thank you. I’m a noobie to flash and tweening was a dark art until you shone a bright light on it. Now, with your help, it’s so simple. I’m as chuffed as a squirrel in a hazelnut tree.
And…You ‘play fair’ with your donation-ware approach. Deep love and respect.
THANK YOU! This is a great tool. You certainly deserve my donation and I’ll be donating more as I can. You’ve saved me hours of time and raised the bar on the work. Thanks again.
Now THAT is best stuff ever! Good work! This saved my ass…and coding at 290 km/h speeding through the republic – updating repositories online all the time, hearing Mozart full power is just insane ![]()
Thank you very much for this awesome work!
Thank you so much for that excellent tweening engine. It’s amazingly fast and versatile. I switched from tweener and I’m very happy!
You leave other programmers to shame.. I LOVE IT WHEN IT HURTS!!!
The fact your engine comes with Gaia Flash Framework by default means it is top dog. I’m switching ASAP.
No room left here for compliments
, so here is a question : how to use reverse() WITHOUT reversing the ease ?
thanx alot
Guy
Thanks Guy. To answer your question, it’s a bit of a tricky issue because a true reverse doesn’t change anything in the tween – time simply passes in the opposite direction, but what you’re asking for is more of a “flip” which could be accomplished using two sequenced tweens. Feel free to dump them into a TimelineMax if you want to control it as a group. Here are two options for creating an infinite loop like that:
new TimelineMax({tweens:[[mc, 1, {x:"100", ease:Strong.easeOut}], [mc, 1, {x:"-100", ease:Strong.easeOut}]], align:TweenAlign.SEQUENCE, repeat:-1});
-OR-
function doTween1():void {
TweenLite.to(mc, 1, {x:”100″, ease:Strong.easeOut, onComplete:doTween2});
}
function doTween2():void {
TweenLite.to(mc, 1, {x:”-100″, ease:Strong.easeOut, onComplete:doTween1});
}
doTween1();
Could you shed some light on how to do the following:
varStr:String = “Back.easeOut”
TweenLite.to(myScrollbar.scrollTarget, transTime, { y: -scrollPos, ease:varStr} );
I’ve written a scrollbar where I want the user to be able to pass in easing type as a string argument. However the above will not work as ease: requires a Function not a String.
Is there a way other than getDefinitionByName ? Cause if you use getDefinitionByName then it seems I also have to specify the different easing types as variables in the Class I’m writing…
Thankful for reply
Thomas
Sure, Thomas, you can use the EaseLookup class to translate Strings into the easing functions. The reason I don’t build that directly into TweenLite/Max is because it forces all the easing equations to be embedded in your SWF which most people don’t need, and it eats up extra kb. Check out the documentation at the top of the EaseLookup class for usage instructions (don’t worry, it’s really easy). It’s in the easing package (gs.easing for v10, and com.greensock.easing in v11 and later).
LOVE THE CLASSES!
I can’t stress this enough. Guys (and gals) give the man some $ for his work. Imagine what your work would look like and how it would flow if you didn’t have his classes.
Great work, Jack.
Jack, you clearly have a passion for writing beautiful, feature filled code. There’s no way you’d offer the community so many great classes, while asking for so little, if you didn’t.
You’ve already saved me a lot of time on my current project.
I’m looking forward to using it with some papervision3d classes.
Let’s pay this man!! .
Thank you so much Jack!!
Wonderful job with the final release of TweenMax / Tweenlite v11.
Thanks again for your dedication, you allowed me to easily enter the industry.
Great Jack!
It’s always a pleasure to be a member of the Club GreenSock! Your AS3 classes work perfectly
Good Job!!!
I’ve been working with some large bitmaps for a screen saver. Things were getting sluggish moving around those big bitmaps, and I noticed the problem was increasing with the more files I added.
autoAlpha just increase my performance huge! I did not realize that when alpha was set just to zero that Flash was still rendering the graphics. (I guess that makes sense if you still want to capture mouse events, but pretty useless for this application).
This and changing my frame rate to 60, really helped smooth out those large bitmaps!
Thanks again!
Justin









