Packagecom.greensock
Classpublic class TweenLite
InheritanceTweenLite Inheritance Animation Inheritance Object
Subclasses TweenMax

TweenLite is an extremely fast, lightweight, and flexible animation tool that serves as the foundation of the GreenSock Animation Platform (GSAP), available in AS2, AS3, and JavaScript. A TweenLite instance handles tweening one or more properties of any object (or array of objects) over time. TweenLite can be used on its own to accomplish most animation chores with minimal file size or it can be use in conjuction with advanced sequencing tools like TimelineLite or TimelineMax to make complex tasks much simpler. With scores of other animation frameworks to choose from, why consider the GreenSock Animation Platform?:

USAGE

The most common type of tween is a to() tween which allows you to define the destination values:

TweenLite.to(myObject, 2, {x:100, y:200});

The above code will tween myObject.x from whatever it currently is to 100 and myObject.y property to 200 over the course of 2 seconds. Notice the x and y values are defined inside a generic object (between curly braces). Put as many properties there as you want.

By default, tweens begin immediately, although you can delay them using the delay special property or pause them initially using the paused special property (see below).

The target can also be an array of objects. For example, the following tween will tween the alpha property to 0.5 and y property to 100 for obj1, obj2, and obj3:

TweenLite.to([obj1, obj2, obj3], 1, {alpha:0.5, y:100});

You can also use a from() tween if you want to define the starting values instead of the ending values so that the target tweens from the defined values to wherever they currently are. Or a fromTo() lets you define both starting and ending values.

Although the to(), from(), and fromTo() static methods are popular because they're quick and can avoid some garbage collection hassles, you can also use the more object-oriented syntax like this:

var tween = new TweenLite(myObject, 2, {x:100, y:200});

or even:

var tween = TweenLite.to(myObject, 2, {x:100, y:200});

SPECIAL PROPERTIES (no plugins required):

Typically the vars parameter is used to define ending values for tweening properties of the target (or beginning values for from() tweens) like {x:100, y:200, alpha:0}, but the following optional special properties serve other purposes:

AS3 note: In AS3, using a TweenLiteVars instance instead of a generic object to define your vars is a bit more verbose but provides code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

PLUGINS:

Think of plugins like special properties that are dynamically added, delivering extra abilities without forcing them to be baked into the core engine, keeping it relatively lean and mean. Each plugin is associated with a property name and it takes responsibility for handling that property. For example, the TintPlugin is associated with the "tint" property name so if it is activated it will intercept the "tint" property in the following tween and manage it uniquely:

TweenLite.to(mc, 1, {tint:0xFF0000});

If the TintPlugin wasn't activated, TweenLite would act as though you were trying to literally tween the mc.tint property (and there is no such thing).

In the JavaScript version of TweenLite, activating a plugin is as simple as loading the associated .js file. No extra activation code is necessary. In the ActionScript version, activating a plugin requires a single line of code and you only need to do it once, 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, TintPlugin]);

To make it even easier, there is a 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 displays interactive examples of each plugin and the assocaited code so that it’s easy to see the correct syntax.

EXAMPLES:

Please see http://www.greensock.com for examples, tutorials, and interactive demos.

NOTES / TIPS:

Copyright 2006-2013, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.



Public Properties
 PropertyDefined By
 Inheriteddata : *
A place to store any data you want (initially populated with vars.data if it exists).
Animation
  defaultEase : Ease
[static] Provides An easy way to change the default easing equation.
TweenLite
  defaultOverwrite : String = auto
[static] Provides An easy way to change the default overwrite mode.
TweenLite
  target : Object
[READ-ONLY] Target object (or array of objects) whose properties the tween affects.
TweenLite
  ticker : Shape
[static] The object that dispatches a "tick" event each time the engine updates, making it easy for you to add your own listener(s) to run custom logic after each update (great for game developers).
TweenLite
 Inheritedtimeline : SimpleTimeline
[Read-only] Parent timeline.
Animation
 Inheritedvars : Object
The vars object passed into the constructor which stores configuration variables like onComplete, onUpdate, etc.
Animation
Public Methods
 MethodDefined By
  
TweenLite(target:Object, duration:Number, vars:Object)
Constructor
TweenLite
 Inherited
delay(value:Number):*
Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin.
Animation
  
delayedCall(delay:Number, callback:Function, params:Array = null, useFrames:Boolean = false):TweenLite
[static] Provides a simple way to call a function after a set amount of time (or frames).
TweenLite
 Inherited
duration(value:Number):*
Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax).
Animation
 Inherited
eventCallback(type:String, callback:Function = null, params:Array = null):*
Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback.
Animation
  
from(target:Object, duration:Number, vars:Object):TweenLite
[static] Static method for creating a TweenLite instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for doing things like animating objects onto the screen because you can set them up initially the way you want them to look at the end of the tween and then animate in from elsewhere.
TweenLite
  
fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object):TweenLite
[static] Static method for creating a TweenLite instance that allows you to define both the starting and ending values (as opposed to to() and from() tweens which are based on the target's current values at one end or the other).
TweenLite
  
getTweensOf(target:*, onlyActive:Boolean = false):Array
[static] Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes.
TweenLite
  
[override] Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values.
TweenLite
 Inherited
isActive():Boolean
Indicates whether or not the animation is currently active (meaning the virtual playhead is actively moving across this instance's time span and it is not paused, nor are any of its ancestor timelines).
Animation
 Inherited
kill(vars:Object = null, target:Object = null):*
Kills the animation entirely or in part depending on the parameters.
Animation
  
killDelayedCallsTo(func:Function):void
[static] Immediately kills all of the delayedCalls to a particular function.
TweenLite
  
killTweensOf(target:*, onlyActive:* = false, vars:Object = null):void
[static] Kills all the tweens (or specific tweening properties) of a particular object or delayedCalls to a particular function.
TweenLite
 Inherited
pause(atTime:* = null, suppressEvents:Boolean = true):*
Pauses the instance, optionally jumping to a specific time.
Animation
 Inherited
paused(value:Boolean = false):*
Gets or sets the animation's paused state which indicates whether or not the animation is currently paused.
Animation
 Inherited
play(from:* = null, suppressEvents:Boolean = true):*
Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is).
Animation
 Inherited
progress(value:Number, suppressEvents:Boolean = false):*
Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete).
Animation
 Inherited
restart(includeDelay:Boolean = false, suppressEvents:Boolean = true):*
Restarts and begins playing forward from the beginning.
Animation
 Inherited
resume(from:* = null, suppressEvents:Boolean = true):*
Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first.
Animation
 Inherited
reverse(from:* = null, suppressEvents:Boolean = true):*
Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease.
Animation
 Inherited
reversed(value:Boolean = false):*
Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards.
Animation
 Inherited
seek(time:*, suppressEvents:Boolean = true):*
Jumps to a specific time without affecting whether or not the instance is paused or reversed.
Animation
  
set(target:Object, vars:Object):TweenLite
[static] Immediately sets properties of the target accordingly - essentially a zero-duration to() tween with a more intuitive name.
TweenLite
 Inherited
startTime(value:Number):*
Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined).
Animation
 Inherited
time(value:Number, suppressEvents:Boolean = false):*
Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration.
Animation
 Inherited
timeScale(value:Number):*
Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc.
Animation
  
to(target:Object, duration:Number, vars:Object):TweenLite
[static] Static method for creating a TweenLite instance that animates to the specified destination values (from the current values).
TweenLite
 Inherited
totalDuration(value:Number):*
Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax).
Animation
 Inherited
totalProgress(value:Number, suppressEvents:Boolean = false):*
Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete).
Animation
 Inherited
totalTime(time:Number, suppressEvents:Boolean = false, uncapped:Boolean = false):*
Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax).
Animation
Property Detail
defaultEaseproperty
public static var defaultEase:Ease

Provides An easy way to change the default easing equation. Choose from any of the GreenSock eases in the com.greensock.easing package.

The default value is Power1.easeOut.

defaultOverwriteproperty 
public static var defaultOverwrite:String = auto

Provides An easy way to change the default overwrite mode. Choose from any of the following: "auto", "all", "none", "allOnStart", "concurrent", "preexisting".

The default value is "auto".

targetproperty 
public var target:Object

[READ-ONLY] Target object (or array of objects) whose properties the tween affects.

tickerproperty 
public static var ticker:Shape

The object that dispatches a "tick" event each time the engine updates, making it easy for you to add your own listener(s) to run custom logic after each update (great for game developers). Add as many listeners as you want. The basic syntax is the same for all versions (AS2, AS3, and JavaScript):

Basic example (AS2, AS3, and JavaScript):

 //add listener
 TweenLite.ticker.addEventListener("tick", myFunction);
 
 function myFunction(event) {
     //executes on every tick after the core engine updates
 }
         
 //to remove the listener later...
 TweenLite.ticker.removeEventListener("tick", myFunction);
         

Due to differences in the core languages (and to maximize efficiency), the advanced syntax is slightly different for the AS3 version compared to AS2 and JavaScript. The parameters beyond the first 2 in the addEventListener() method are outlined below:

JavaScript and AS2

addEventListener(type, callback, scope, useParam, priority)

Parameters:

  1. type : String - type of listener, should always be "tick"
  2. callback : Function - the function to call when the event occurs
  3. scope : Object - binds the scope to a particular object (scope is basically what "this" refers to in your function). This can be very useful in JavaScript and AS2 because scope isn't generally maintained.
  4. useParam : Boolean - if true, an event object will be generated and fed to the callback each time the event occurs. The event is a generic object and has two properties: type (always "tick") and target which refers to the ticker instance. The default for useParam is false because it improves performance.
  5. priority : Integer - influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.

Advanced example (JavaScript and AS2):

 //add listener that requests an event object parameter, binds scope to the current scope (this), and sets priority to 1 so that it is called before any other listeners that had a priority lower than 1...
 TweenLite.ticker.addEventListener("tick", myFunction, this, true, 1);
 
 function myFunction(event) {
     //executes on every tick after the core engine updates
 }
 
 //to remove the listener later...
 TweenLite.ticker.removeEventListener("tick", myFunction);
         

AS3

The AS3 version uses the standard EventDispatcher.addEventListener() syntax which basically allows you to define a priority and whether or not to use weak references (see Adobe's docs for details).

Advanced example [AS3 only]:

 import flash.events.Event;
 
 //add listener with weak reference (standard syntax - notice the 5th parameter is true)
 TweenLite.ticker.addEventListener("tick", myFunction, false, 0, true);
 
 function myFunction(event:Event):void {
     //executes on every tick after the core engine updates
 }
 
 //to remove the listener later...
 TweenLite.ticker.removeEventListener("tick", myFunction);
        

Constructor Detail
TweenLite()Constructor
public function TweenLite(target:Object, duration:Number, vars:Object)

Constructor

Parameters
target:Object — Target object (or array of objects) whose properties this tween affects
 
duration:Number — Duration in seconds (or frames if useFrames:true is set in the vars parameter)
 
vars:Object — An object defining the end value for each property that should be tweened as well as any special properties like onComplete, ease, etc. For example, to tween mc.x to 100 and mc.y to 200 and then call myFunction, do this: new TweenLite(mc, 1, {x:100, y:200, onComplete:myFunction}).
Method Detail
delayedCall()method
public static function delayedCall(delay:Number, callback:Function, params:Array = null, useFrames:Boolean = false):TweenLite

Provides a simple way to call a function after a set amount of time (or frames). You can optionally pass any number of parameters to the function too.

JavaScript and AS2 note: - Due to the way JavaScript and AS2 don't maintain scope (what "this" refers to, or the context) in function calls, it can be useful to define the scope specifically. Therefore, in the JavaScript and AS2 versions the 4th parameter is scope, bumping useFrames back to the 5th parameter:

TweenLite.delayedCall(delay, callback, params, scope, useFrames) [JavaScript and AS2 only]

//calls myFunction after 1 second and passes 2 parameters:
TweenLite.delayedCall(1, myFunction, ["param1", 2]);
 
function myFunction(param1, param2) {
    //do stuff
}

Parameters

delay:Number — Delay in seconds (or frames if useFrames is true) before the function should be called
 
callback:Function — Function to call
 
params:Array (default = null) — An Array of parameters to pass the function (optional).
 
useFrames:Boolean (default = false) — If the delay should be measured in frames instead of seconds, set useFrames to true (default is false)

Returns
TweenLite — TweenLite instance

See also

from()method 
public static function from(target:Object, duration:Number, vars:Object):TweenLite

Static method for creating a TweenLite instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for doing things like animating objects onto the screen because you can set them up initially the way you want them to look at the end of the tween and then animate in from elsewhere.

NOTE: By default, immediateRender is true in from() tweens, meaning that they immediately render their starting state regardless of any delay that is specified. You can override this behavior by passing immediateRender:false in the vars parameter so that it will wait to render until the tween actually begins (often the desired behavior when inserting into TimelineLite or TimelineMax instances). To illustrate the default behavior, the following code will immediately set the alpha of mc to 0 and then wait 2 seconds before tweening the alpha back to 1 over the course of 1.5 seconds:

TweenLite.from(mc, 1.5, {alpha:0, delay:2});

Since the target parameter can also be an array of objects, the following code will tween the alpha property of mc1, mc2, and mc3 from a value of 0 simultaneously:

TweenLite.from([mc1, mc2, mc3], 1.5, {alpha:0});

Even though 3 objects are animating, there is still only one tween created. In order to stagger or offset the start times of each object animating, please see the staggerFrom() method of TimelineLite or TweenMax.

For simple sequencing, you can use the delay special property (like TweenLite.from(mc, 1, {alpha:0, delay:0.5})), but it is highly recommended that you consider using TimelineLite (or TimelineMax) for all but the simplest sequencing tasks. It has an identical from() method that allows you to append tweens one-after-the-other and then control the entire sequence as a whole. You can even have the tweens overlap as much as you want.

Parameters

target:Object — Target object (or array of objects) whose properties this tween affects.
 
duration:Number — Duration in seconds (or frames if useFrames:true is set in the vars parameter)
 
vars:Object — An object defining the starting value for each property that should be tweened as well as any special properties like onComplete, ease, etc. For example, to tween mc.x from 100 and mc.y from 200 and then call myFunction, do this: TweenLite.from(mc, 1, {x:100, y:200, onComplete:myFunction});

Returns
TweenLite — TweenLite instance

See also

fromTo()method 
public static function fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object):TweenLite

Static method for creating a TweenLite instance that allows you to define both the starting and ending values (as opposed to to() and from() tweens which are based on the target's current values at one end or the other).

NOTE: Only put starting values in the fromVars parameter - all special properties for the tween (like onComplete, onUpdate, delay, etc.) belong in the toVars parameter.

By default, immediateRender is true in fromTo() tweens, meaning that they immediately render their starting state regardless of any delay that is specified. This is done for convenience because it is often the preferred behavior when setting things up on the screen to animate into place, but you can override this behavior by passing immediateRender:false in the fromVars or toVars parameter so that it will wait to render the starting values until the tween actually begins (often the desired behavior when inserting into TimelineLite or TimelineMax instances).

Since the target parameter can also be an array of objects, the following code will tween the x property of mc1, mc2, and mc3 from 0 to 100 simultaneously:

TweenLite.fromTo([mc1, mc2, mc3], 1, {x:0}, {x:100});

Even though 3 objects are animating, there is still only one tween created. In order to stagger or offset the start times of each object animating, please see the staggerFromTo() method of TimelineLite or TweenMax.

For simple sequencing, you can use the delay special property (like TweenLite.fromTo(mc, 1, {x:0}, {x:100, delay:0.5})), but it is highly recommended that you consider using TimelineLite (or TimelineMax) for all but the simplest sequencing tasks. It has an identical fromTo() method that allows you to append tweens one-after-the-other and then control the entire sequence as a whole. You can even have the tweens overlap as much as you want.

Parameters

target:Object — Target object (or array of objects) whose properties this tween affects.
 
duration:Number — Duration in seconds (or frames if useFrames:true is set in the vars parameter)
 
fromVars:Object — An object defining the starting value for each property that should be tweened. For example, to tween mc.x from 100 and mc.y from 200, fromVars would look like this: {x:100, y:200}.
 
toVars:Object — An object defining the end value for each property that should be tweened as well as any special properties like onComplete, ease, etc. For example, to tween mc.x from 0 to 100 and mc.y from 0 to 200 and then call myFunction, do this: TweenLite.fromTo(mc, 1, {x:0, y:0}, {x:100, y:200, onComplete:myFunction});

Returns
TweenLite — TweenLite instance

See also

getTweensOf()method 
public static function getTweensOf(target:*, onlyActive:Boolean = false):Array

Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes. For example, TweenLite.getTweensOf(myObject) returns an array of all tweens of myObject, even tweens that haven't begun yet. TweenLite.getTweensOf([myObject1, myObject2]); will return a condensed array of the tweens of myObject1 plus all the tweens of myObject2 combined into one array with duplicates removed.

Since the method only finds tweens that haven't been released for garbage collection, if you create a tween and then let it finish and then a while later try to find it with getTweensOf(), it may not be found because it was released by the engine for garbage collection. Remember, one of the best parts of GSAP is that it saves you from the headache of managing gc. Otherwise, you'd need to manually dispose each tween you create, making things much more cumbersome.

TweenLite.to(myObject1, 1, {x:100});
TweenLite.to(myObject2, 1, {x:100});
TweenLite.to([myObject1, myObject2], 1, {alpha:0});
var a1 = TweenLite.getTweensOf(myObject1); //finds 2 tweens
var a2 = TweenLite.getTweensOf([myObject1, myObject2]); //finds 3 tweens

Parameters

target:* — The target whose tweens should be returned, or an array of such targets
 
onlyActive:Boolean (default = false) — If true, only tweens that are currently active will be returned (a tween is considered "active" if the virtual playhead is actively moving across the tween and it is not paused, nor are any of its ancestor timelines paused).

Returns
Array — An array of tweens
invalidate()method 
override public function invalidate():*

Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. When you invalidate() an animation, it will be re-initialized the next time it renders and its vars object will be re-parsed. The timing of the animation (duration, startTime, delay) will not be affected.

Another example would be if you have a TweenMax(mc, 1, {x:100, y:100}) that ran when mc.x and mc.y were initially at 0, but now mc.x and mc.y are 200 and you want them tween to 100 again, you could simply invalidate() the tween and restart() it. Without invalidating first, restarting it would cause the values jump back to 0 immediately (where they started when the tween originally began). When you invalidate a TimelineLite/TimelineMax, it automatically invalidates all of its children.

Returns
* — self (makes chaining easier)
killDelayedCallsTo()method 
public static function killDelayedCallsTo(func:Function):void

Immediately kills all of the delayedCalls to a particular function. If, for example, you want to kill all delayedCalls to myFunction, you'd do this:

TweenLite.killDelayedCallsTo(myFunction);

Since a delayedCall is just a tween that uses the function/callback as both its target and its onComplete, TweenLite.killTweensOf(myFunction) produces exactly the same result as TweenLite.killDelayedCallsTo(myFunction).

This method affects all delayedCalls that were created using TweenLite.delayedCall() or TweenMax.delayedCall() or the call() or addCallback() methods of TimelineLite or TimelineMax. Basically, any tween whose target is the function you supply will be killed.

Parameters

func:Function — The function for which all delayedCalls should be killed/cancelled.

killTweensOf()method 
public static function killTweensOf(target:*, onlyActive:* = false, vars:Object = null):void

Kills all the tweens (or specific tweening properties) of a particular object or delayedCalls to a particular function. If, for example, you want to kill all tweens of myObject, you'd do this:

TweenLite.killTweensOf(myObject);

To kill only active (currently animating) tweens of myObject, you'd do this:

TweenLite.killTweensOf(myObject, true);

To kill only particular tweening properties of the object, use the third parameter. For example, if you only want to kill all the tweens of myObject.alpha and myObject.x, you'd do this:

TweenLite.killTweensOf(myObject, false, {alpha:true, x:true});

To kill all the delayedCalls that were created like TweenLite.delayedCall(5, myFunction);, you can simply call TweenLite.killTweensOf(myFunction); because delayedCalls are simply tweens that have their target and onComplete set to the same function (as well as a delay of course).

killTweensOf() affects tweens that haven't begun yet too. If, for example, a tween of myObject has a delay of 5 seconds and TweenLite.killTweensOf(mc) is called 2 seconds after the tween was created, it will still be killed even though it hasn't started yet.

Parameters

target:* — Object whose tweens should be killed immediately or selector text to feed the selector engine to find the target(s).
 
onlyActive:* (default = false) — If true, only tweens that are currently active will be killed (a tween is considered "active" if the virtual playhead is actively moving across the tween and it is not paused, nor are any of its ancestor timelines paused).
 
vars:Object (default = null) — To kill only specific properties, use a generic object containing enumerable properties corresponding to the ones that should be killed like {x:true, y:true}. The values assigned to each property of the object don't matter - the sole purpose of the object is for iteration over the named properties (in this case, x and y). If no object (or null) is defined, all matched tweens will be killed in their entirety.

set()method 
public static function set(target:Object, vars:Object):TweenLite

Immediately sets properties of the target accordingly - essentially a zero-duration to() tween with a more intuitive name. So the following lines produce identical results:

TweenLite.set(myObject, {x:100, y:50, alpha:0});
TweenLite.to(myObject, 0, {x:100, y:50, alpha:0});

And of course you can use an array to set the properties of multiple targets at the same time, like:

TweenLite.set([obj1, obj2, obj3], {x:100, y:50, alpha:0});

Parameters

target:Object — Target object (or array of objects) whose properties will be affected.
 
vars:Object — An object defining the value for each property that should be set. For example, to set mc.x to 100 and mc.y to 200, do this: TweenLite.set(mc, {x:100, y:200});

Returns
TweenLite — A TweenLite instance (with a duration of 0) which can optionally be inserted into a TimelineLite/Max instance (although it's typically more concise to just use the timeline's set() method).
to()method 
public static function to(target:Object, duration:Number, vars:Object):TweenLite

Static method for creating a TweenLite instance that animates to the specified destination values (from the current values). The following lines of code all produce identical results:

TweenLite.to(mc, 1, {x:100});
var myTween = new TweenLite(mc, 1, {x:100});
var myTween = TweenLite.to(mc, 1, {x:100});

Each line above will tween the "x" property of the mc object to a value of 100 over the coarse of 1 second. They each use a slightly different syntax, all of which are valid. If you don't need to store a reference of the tween, just use the static TweenLite.to( ) call.

Since the target parameter can also be an array of objects, the following code will tween the x property of mc1, mc2, and mc3 to a value of 100 simultaneously:

TweenLite.to([mc1, mc2, mc3], 1, {x:100});

Even though 3 objects are animating, there is still only one tween created. In order to stagger or offset the start times of each object animating, please see the staggerTo() method of TimelineLite or TweenMax.

For simple sequencing, you can use the delay special property (like TweenLite.to(mc, 1, {x:100, delay:0.5})), but it is highly recommended that you consider using TimelineLite (or TimelineMax) for all but the simplest sequencing tasks. It has an identical to() method that allows you to append tweens one-after-the-other and then control the entire sequence as a whole. You can even have the tweens overlap as much as you want.

Parameters

target:Object — Target object (or array of objects) whose properties this tween affects.
 
duration:Number — Duration in seconds (or frames if useFrames:true is set in the vars parameter)
 
vars:Object — An object defining the end value for each property that should be tweened as well as any special properties like onComplete, ease, etc. For example, to tween mc.x to 100 and mc.y to 200 and then call myFunction, do this: TweenLite.to(mc, 1, {x:100, y:200, onComplete:myFunction});

Returns
TweenLite — TweenLite instance

See also