Packagecom.greensock
Classpublic class TimelineLite
InheritanceTimelineLite Inheritance SimpleTimeline Inheritance Animation Inheritance Object
Subclasses TimelineMax

TimelineLite is a powerful sequencing tool that acts as a container for tweens and other timelines, making it simple to control them as a whole and precisely manage their timing in relation to each other. Without TimelineLite (or its big brother TimelineMax), building complex sequences would be far more cumbersome because you'd need to use the delay special property for everything which would make future edits far more tedious. Here is a basic example of a sequence without using TimelineLite (the tedious way):
TweenLite.to(mc, 1, {x:100});
TweenLite.to(mc, 1, {y:50, delay:1});
TweenLite.to(mc, 1, {alpha:0, delay:2});
The above code animates mc.x to 100, then mc.y to 50, and finally mc.alpha to 0 (notice the delay in all but the first tween). But imagine if you wanted to increase the duration of the first tween to 1.5 - you'd need to adjust every delay thereafter. And what if you want to pause() the whole sequence or restart() it or reverse() it on-the-fly or jump to a specific point in the whole animation? This becomes quite messy (or flat-out impossible), but TimelineLite makes it incredibly simple:
var tl = new TimelineLite();
tl.add( TweenLite.to(mc, 1, {x:100}) );
tl.add( TweenLite.to(mc, 1, {y:50}) );
tl.add( TweenLite.to(mc, 1, {alpha:0}) );
 
//then later, control the whole thing...
tl.pause();
tl.resume();
tl.seek(1.5);
tl.reverse();
...
Or use the convenient to() method and chaining to make it even more concise:
var tl = new TimelineLite();
tl.to(mc, 1, {x:100}).to(mc, 1, {y:50}).to(mc, 1, {alpha:0});

Now you can adjust any of the tweens without worrying about trickle-down changes to delays. Increase the duration of that first tween and everything automatically adjusts!

Here are some other benefits and features of TimelineLite:

SPECIAL PROPERTIES:

You can optionally use the constructor's vars parameter to define any of the special properties below (syntax example: new TimelineLite({onComplete:myFunction, delay:2});

Sample code:
//create the timeline with an onComplete callback that calls myFunction() when the timeline completes
var tl = new TimelineLite({onComplete:myFunction});
//add a tween
tl.add( new TweenLite(mc, 1, {x:200, y:100}) );
        
//add another tween at the end of the timeline (makes sequencing easy)
tl.add( new TweenLite(mc, 0.5, {alpha:0}) );
 
//append a tween using the convenience method (shorter syntax) and offset it by 0.5 seconds
tl.to(mc, 1, {rotation:30}, "+=0.5");
         
//reverse anytime
tl.reverse();
//Add a "spin" label 3-seconds into the timeline
tl.add("spin", 3);
//insert a rotation tween at the "spin" label (you could also define the insertion point as the time instead of a label)
tl.add( new TweenLite(mc, 2, {rotation:"360"}), "spin");
    
//go to the "spin" label and play the timeline from there
tl.play("spin");
//nest another TimelineLite inside your timeline...
var nested = new TimelineLite();
nested.to(mc2, 1, {x:200}));
tl.add(nested);

How do timelines work? What are the mechanics like?

Every animation (tween and timeline) is placed on a parent timeline (except the 2 root timelines - there's one for normal tweens and another for "useFrames" ones). In a sense, they all have their own playheads (that's what its "time" refers to, or "totalTime" which is identical except that it includes repeats and repeatDelays) but generally they're not independent because they're sitting on a timeline whose playhead moves. When the parent's playhead moves to a new position, it updates the childrens' too.

When a timeline renders at a particular time, it loops through its children and says "okay, you should render as if your playhead is at ____" and if that child is a timeline with children, it does the same to its children, right on down the line.

The only exception is when the tween/timeline is paused in which case its internal playhead acts like it's "locked". So in that case, it's possible (likely in fact) that the child's playhead would not be synced with the parent's. When you unpause it (resume()), it essentially picks it up and moves it so that its internal playhead is synchronized with wherever the parent's playhead is at that moment, thus things play perfectly smoothly. That is, unless the timeline's smoothChildTiming is to false in which case it won't move - its startTime will remain locked to where it was.

So basically, when smoothChildTiming is true, the engine will rearrange things on the fly to ensure the playheads line up so that playback is seamless and smooth. The same thing happens when you reverse() or alter the timeScale, etc. But sometimes you might not want that behavior - you prefer to have tight control over exactly where your tweens line up in the timeline - that's when smoothChildTiming:false is handy.

One more example: let's say you've got a 10-second tween that's just sitting on the root timeline and you're 2-seconds into the tween. Let's assume it started at exactly 0 on the root to make this easy, and then when it's at 2-seconds, you do tween.seek(5). The playhead of the root isn't affected - it keeps going exactly as it always did, but in order to make that tween jump to 5 seconds and play appropriately, the tween's startTime gets changed to -3. That way, the tween's playhead and the root playhead are perfectly aligned.

Copyright 2008-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
 InheritedautoRemoveChildren : Boolean
If true, child tweens/timelines will be removed as soon as they complete.
SimpleTimeline
 Inheriteddata : *
A place to store any data you want (initially populated with vars.data if it exists).
Animation
 InheritedsmoothChildTiming : Boolean
Controls whether or not child tweens/timelines are repositioned automatically (changing their startTime) in order to maintain smooth playback when properties are changed on-the-fly.
SimpleTimeline
 Inheritedticker : 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).
Animation
 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
  
TimelineLite(vars:Object = null)
Constructor.
TimelineLite
  
add(value:*, position:* = +=0, align:String = normal, stagger:Number = 0):*
[override] Adds a tween, timeline, callback, or label (or an array of them) to the timeline.
TimelineLite
  
addLabel(label:String, position:* = +=0):*
Adds a label to the timeline, making it easy to mark important positions/times.
TimelineLite
  
addPause(position:* = +=0, callback:Function = null, params:Array = null):*
Inserts a special callback that pauses playback of the timeline at a particular time or label.
TimelineLite
  
call(callback:Function, params:Array = null, position:* = +=0):*
Adds a callback to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.delayedCall(...) ) but with less code.
TimelineLite
  
clear(labels:Boolean = true):*
Empties the timeline of all tweens, timelines, and callbacks (and optionally labels too).
TimelineLite
 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
  
duration(value:Number):*
[override] Gets the timeline's duration or, if used as a setter, adjusts the timeline's timeScale to fit it within the specified duration.
TimelineLite
 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
  
exportRoot(vars:Object = null, omitDelayedCalls:Boolean = true):TimelineLite
[static] Seamlessly transfers all tweens, timelines, and [optionally] delayed calls from the root timeline into a new TimelineLite so that you can perform advanced tasks on a seemingly global basis without affecting tweens/timelines that you create after the export.
TimelineLite
  
from(target:Object, duration:Number, vars:Object, position:* = +=0):*
Adds a TweenLite.from() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.from(...) ) but with less code.
TimelineLite
  
fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object, position:* = +=0):*
Adds a TweenLite.fromTo() tween to the end of the timeline - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.fromTo(...) ) but with less code.
TimelineLite
  
getChildren(nested:Boolean = true, tweens:Boolean = true, timelines:Boolean = true, ignoreBeforeTime:Number = -9999999999):Array
Returns an array containing all the tweens and/or timelines nested in this timeline.
TimelineLite
  
getLabelTime(label:String):Number
Returns the time associated with a particular label.
TimelineLite
  
getTweensOf(target:Object, nested:Boolean = true):Array
Returns the tweens of a particular object that are inside this timeline.
TimelineLite
  
[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.
TimelineLite
 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
 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
  
remove(value:*):*
Removes a tween, timeline, callback, or label (or array of them) from the timeline.
TimelineLite
  
removeLabel(label:String):*
Removes a label from the timeline and returns the time of that label.
TimelineLite
 Inherited
render(time:Number, suppressEvents:Boolean = false, force:Boolean = false):void
[override]
SimpleTimeline
 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
  
seek(position:*, suppressEvents:Boolean = true):*
[override] Jumps to a specific time (or label) without affecting whether or not the instance is paused or reversed.
TimelineLite
  
set(target:Object, vars:Object, position:* = +=0):*
Adds a zero-duration tween to the end of the timeline (or elsewhere using the "position" parameter) that sets values immediately (when the virtual playhead reaches that position on the timeline) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.to(target, 0, {...}) ) but with less code.
TimelineLite
  
shiftChildren(amount:Number, adjustLabels:Boolean = false, ignoreBeforeTime:Number = 0):*
Shifts the startTime of the timeline's children by a certain amount and optionally adjusts labels too.
TimelineLite
  
staggerFrom(targets:Array, duration:Number, vars:Object, stagger:Number = 0, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*
Tweens an array of targets from a common set of destination values (using the current values as the destination), but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code.
TimelineLite
  
staggerFromTo(targets:Array, duration:Number, fromVars:Object, toVars:Object, stagger:Number = 0, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*
Tweens an array of targets from and to a common set of values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code.
TimelineLite
  
staggerTo(targets:Array, duration:Number, vars:Object, stagger:Number, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*
Tweens an array of targets to a common set of destination values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code.
TimelineLite
 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
  
stop():*
[deprecated] Pauses the timeline (used for consistency with Flash's MovieClip.stop() functionality, but essentially accomplishes the same thing as pause() without the parameter)
TimelineLite
 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, position:* = +=0):*
Adds a TweenLite.to() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.to(...) ) but with less code.
TimelineLite
  
totalDuration(value:Number):*
[override] Gets the timeline's total duration or, if used as a setter, adjusts the timeline's timeScale to fit it within the specified duration.
TimelineLite
 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
  
usesFrames():Boolean
[READ-ONLY] If true, the timeline's timing mode is frames-based instead of seconds.
TimelineLite
Constructor Detail
TimelineLite()Constructor
public function TimelineLite(vars:Object = null)

Constructor.

SPECIAL PROPERTIES

The following special properties may be passed in via the constructor's vars parameter, like new TimelineLite({paused:true, onComplete:myFunction})

Parameters
vars:Object (default = null) — optionally pass in special properties like onComplete, onCompleteParams, onUpdate, onUpdateParams, onStart, onStartParams, tweens, align, stagger, delay, useFrames, and/or autoRemoveChildren.
Method Detail
add()method
override public function add(value:*, position:* = +=0, align:String = normal, stagger:Number = 0):*

Adds a tween, timeline, callback, or label (or an array of them) to the timeline.

The position parameter gives you complete control over the insertion point. By default, it's at the end of the timeline. Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the object 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the object inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the object 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

//add a tween to the end of the timeline
tl.add( TweenLite.to(mc, 2, {x:100}) );
//add a callback at 1.5 seconds
tl.add(func, 1.5); 
//add a label 2 seconds after the end of the timeline (with a gap of 2 seconds)
tl.add("myLabel", "+=2");
//add another timeline at "myLabel"
tl.add(otherTimeline, "myLabel"); 
//add an array of tweens 2 seconds after "myLabel"
tl.add([tween1, tween2, tween3], "myLabel+=2"); 
//add an array of tweens so that they are sequenced one-after-the-other with 0.5 seconds inbetween them, starting 2 seconds after the end of the timeline
tl.add([tween1, tween2, tween3], "+=2", "sequence", 0.5);

Parameters

value:* — The tween, timeline, callback, or label (or array of them) to add
 
position:* (default = +=0) — Controls the placement of the object in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the object 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the object inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the object 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.
 
align:String (default = normal)[only relevant when the first parameter, value, is an array] Determines how the tweens/timelines/callbacks/labels in the array that is being added will be aligned in relation to each other before getting inserted. Options are: "sequence" (aligns them one-after-the-other in a sequence), "start" (aligns the start times of all of the objects (ignoring delays)), and "normal" (aligns the start times of all the tweens (honoring delays)). The default is "normal".
 
stagger:Number (default = 0)[only relevant when the first parameter, value, is an array] Staggers the inserted objects from the array the is being added by a set amount of time (in seconds) (or in frames for frames-based timelines). For example, if the stagger value is 0.5 and the "align" parameter is set to "start", the second one will start 0.5 seconds after the first one starts, then 0.5 seconds later the third one will start, etc. If the align property is "sequence", there would be 0.5 seconds added between each tween. Default is 0.

Returns
* — self (makes chaining easier)
addLabel()method 
public function addLabel(label:String, position:* = +=0):*

Adds a label to the timeline, making it easy to mark important positions/times. You can then reference that label in other methods, like seek("myLabel") or add(myTween, "myLabel") or reverse("myLabel"). You could also use the add() method to insert a label.

Parameters

label:String — The name of the label
 
position:* (default = +=0) — Controls the placement of the label in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the label 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the label inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the label 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the label there which can be quite convenient.

Returns
*
addPause()method 
public function addPause(position:* = +=0, callback:Function = null, params:Array = null):*

Inserts a special callback that pauses playback of the timeline at a particular time or label. This method is more accurate than using a simple callback of your own because it ensures that even if the virtual playhead had moved slightly beyond the pause position, it'll get moved back to precisely the correct position.

Remember, the virtual playhead moves to a new position on each tick (frame) of the core timing mechanism, so it is possible, for example for it to be at 0.99 and then the next render happens at 1.01, so if your callback was at exactly 1 second, the playhead would (in this example) move slightly past where you wanted to pause. Then, if you reverse(), it would run into that callback again and get paused almost immediately. However, if you use the addPause() method, it will calibrate things so that when the callback is hit, it'll move the playhead back to EXACTLY where it should be. Thus, if you reverse() it won't run into the same callback again.

//insert a pause at exactly 2 seconds into the timeline
timeline.addPause(2);
 
//insert a pause at "yourLabel"
timeline.addPause("yourLabel");
 
//insert a pause 3 seconds after "yourLabel" and when that pause occurs, call yourFunction
timeline.addPause("yourLabel+=3", yourFunction);
 
//insert a pause at exactly 4 seconds and then call yourFunction and pass it 2 parameters, "param1" and "param2"
timeline.addPause(4, yourFunction, ["param1", "param2"]);

The special callback is just a zero-duration tween that utilizes an onComplete, so technically this callback is just like any other, and it is considered a child of the timeline.

Parameters

position:* (default = +=0) — Controls the placement of the pause in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.
 
callback:Function (default = null) — An optional callback that should be called immediately after the timeline is paused.
 
params:Array (default = null) — An optional array of parameters to pass the callback.

Returns
* — self (makes chaining easier)

See also

call()method 
public function call(callback:Function, params:Array = null, position:* = +=0):*

Adds a callback to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.delayedCall(...) ) but with less code. In other words, the following two lines produce identical results:

myTimeline.add( TweenLite.delayedCall(0, myFunction, ["param1", "param2"]) );
myTimeline.call(myFunction, ["param1", "param2"]);

This is different than using the onComplete special property on the TimelineLite itself because once you append the callback, it stays in place whereas an onComplete is always called at the very end of the timeline. For example, if a timeline is populated with a 1-second tween and then you call(myFunction), it is placed at the 1-second spot. Then if you append another 1-second tween, the timeline's duration will now be 2 seconds but the myFunction callback will still be called at the 1-second spot. An onComplete would be called at the end (2 seconds).

Keep in mind that you can chain these calls together and use other convenience methods like to(), fromTo(), set(), staggerTo(), etc. to build out sequences very quickly:

//create a timeline that calls myFunction() when it completes
var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
//now we'll use chaining, but break each step onto a different line for readability...
tl.to(mc, 1, {x:100})    //tween mc.x to 100
  .call(myCallback)        //then call myCallback()
  .set(mc, {alpha:0})    //then set mc.alpha to 0.5 immediately
  .call(otherFunction, ["param1", "param2"])    //then call otherFunction("param1", "param2")
  .staggerTo([mc1, mc2, mc3], 1.5, {rotation:45}, 0.25); //finally tween the rotation of mc1, mc2, and mc3 to 45 and stagger the start times by 0.25 seconds

The 3rd parameter is the position which controls the placement of the tween in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween which can be quite convenient.

tl.call(func, ["param1"]);  //appends to the end of the timeline
tl.call(func, ["param1"], 2);  //appends it at exactly 2 seconds into the timeline (absolute position)
tl.call(func, ["param1"], "+=2");  //appends it 2 seconds after the end (with a gap of 2 seconds)
tl.call(func, ["param1"], "myLabel");  //places it at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tween is inserted there)
tl.call(func, ["param1"], "myLabel+=2");  //places it 2 seconds after "myLabel"

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 3rd parameter is scope, but that parameter is omitted in the AS3 version.

Parameters

callback:Function — Function to call
 
params:Array (default = null) — An Array of parameters to pass the function.
 
position:* (default = +=0) — Controls the placement of the callback in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the callback 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the callback inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the callback 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the callback there which can be quite convenient.

Returns
* — self (makes chaining easier)

See also

clear()method 
public function clear(labels:Boolean = true):*

Empties the timeline of all tweens, timelines, and callbacks (and optionally labels too). Event callbacks (like onComplete, onUpdate, onStart, etc.) are not removed. If you need to remove event callbacks, use the eventCallback() method and set them to null like myTimeline.eventCallback("onComplete", null);

Parameters

labels:Boolean (default = true) — If true (the default), labels will be cleared too.

Returns
* — self (makes chaining easier)
duration()method 
override public function duration(value:Number):*

Gets the timeline's duration or, if used as a setter, adjusts the timeline's timeScale to fit it within the specified duration. duration() is identical to totalDuration() except for TimelineMax instances that have a non-zero repeat in which case totalDuration includes repeats and repeatDelays whereas duration doesn't. For example, if a TimelineMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles).

Due to the fact that a timeline's duration is dictated by its contents, using this method as a setter will simply cause the timeScale to be adjusted to fit the current contents into the specified duration, but the duration value itself will remain unchanged. For example, if there are 20-seconds worth of tweens in the timeline and you do myTimeline.duration(10), the timeScale would be changed to 2. If you checked the duration again immediately after that, it would still return 20 because technically that is how long all the child tweens/timelines are but upon playback the speed would be doubled because of the timeScale.

This method serves as both a getter and setter. Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining, like myAnimation.duration(2).play(1);

 var currentDuration = myAnimation.duration(); //gets current duration
 myAnimation.duration( 10 ); //adjusts the timeScale of myAnimation so that it fits into exactly 10 seconds on its parent timeline
         

Parameters

value:Number (default = NaN) — Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

Returns
* — Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

See also

exportRoot()method 
public static function exportRoot(vars:Object = null, omitDelayedCalls:Boolean = true):TimelineLite

Seamlessly transfers all tweens, timelines, and [optionally] delayed calls from the root timeline into a new TimelineLite so that you can perform advanced tasks on a seemingly global basis without affecting tweens/timelines that you create after the export. For example, imagine a game that uses the GreenSock Animation Platform for all of its animations and at some point during the game, you want to slow everything down to a stop (tweening the timeScale) while at the same time animating a new popup window into place:

var tl = TimelineLite.exportRoot();
TweenLite.to(tl, 0.5, {timeScale:0});
//this tween isn't affected because it's created after the export.
TweenLite.fromTo(myWindow, 1, {scaleX:0, scaleY:0}, {scaleX:1, scaleY:1});

You could then re-animate things when you're ready by tweening the timeScale back to 1. Or you could use exportRoot() to collect all the animations and pause() them and then animate the popup screen (or whatever). Then resume() that instance or even reverse().

You can exportRoot() as many times as you want; all it does is wrap all the loose tweens/timelines/delayedCalls into a TimelineLite which itself gets placed onto the root, so if you exportRoot() again, that TimelineLite would get wrapped into another one, etc. Things can be nested as deeply as you want.

Keep in mind, however, that completed tweens/timelines are removed from the root (for automatic garbage collection), so if you exportRoot() after a tween completes, it won't be included in the export. The only way around that is to set autoRemoveChildren property of the Animation._rootTimeline and Animation._rootFramesTimeline to false, but that is NOT recommended because you'd need to manually kill() your tweens/timelines manually to make them eligible for garbage collection.

Parameters

vars:Object (default = null) — The vars parameter that's passed to the TimelineLite's constructor which allows you to define things like onUpdate, onComplete, etc. The useFrames special property determines which root timeline gets exported. There are two distinct root timelines - one for frames-based animations (useFrames:true) and one for time-based ones. By default, the time-based timeline is exported.
 
omitDelayedCalls:Boolean (default = true) — If true (the default), delayed calls will be left on the root rather than wrapped into the new TimelineLite. That way, if you pause() or alter the timeScale, or reverse(), they won't be affected. However, in some situations it might be very useful to have them included.

Returns
TimelineLite — A new TimelineLite instance containing the root tweens/timelines
from()method 
public function from(target:Object, duration:Number, vars:Object, position:* = +=0):*

Adds a TweenLite.from() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.from(...) ) but with less code. In other words, the following two lines produce identical results:

myTimeline.add( TweenLite.from(mc, 1, {x:100, alpha:0.5}) );
myTimeline.from(mc, 1, {x:100, alpha:0.5});

Keep in mind that you can chain these calls together and use other convenience methods like to(), call(), set(), staggerTo(), etc. to build out sequences very quickly:

//create a timeline that calls myFunction() when it completes
var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
//now we'll use chaining, but break each step onto a different line for readability...
tl.from(mc, 1, {x:-100})    //tween mc.x from -100
  .to(mc, 1, {y:50})    //then tween mc.y to 50
  .set(mc, {alpha:0})    //then set mc.alpha to 0.5 immediately
  .call(otherFunction)    //then call otherFunction()
  .staggerTo([mc1, mc2, mc3], 1.5, {rotation:45}, 0.25); //finally tween the rotation of mc1, mc2, and mc3 to 45 and stagger the start times by 0.25 seconds

If you don't want to append the tween and would rather have precise control of the insertion point, you can use the additional position parameter. Or use a regular add() like myTimeline.add( TweenLite.from(mc, 1, {x:100}), 2.75).

The 4th parameter is the position which controls the placement of the tween in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

tl.from(mc, 1, {x:100});  //appends to the end of the timeline
tl.from(mc, 1, {x:100}, 2);  //appends it at exactly 2 seconds into the timeline (absolute position)
tl.from(mc, 1, {x:100}, "+=2");  //appends it 2 seconds after the end (with a gap of 2 seconds)
tl.from(mc, 1, {x:100}, "myLabel");  //places it at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tween is inserted there)
tl.from(mc, 1, {x:100}, "myLabel+=2");  //places it 2 seconds after "myLabel"

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.

Parameters

target:Object — Target object (or array of objects) whose properties the tween affects
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
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: myTimeline.from(mc, 1, {x:100, y:200, onComplete:myFunction});
 
position:* (default = +=0) — Controls the placement of the tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

Returns
* — self (makes chaining easier)

See also

fromTo()method 
public function fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object, position:* = +=0):*

Adds a TweenLite.fromTo() tween to the end of the timeline - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.fromTo(...) ) but with less code. In other words, the following two lines produce identical results:

myTimeline.add( TweenLite.fromTo(mc, 1, {x:0, alpha:1}, {x:100, alpha:0.5}) );
myTimeline.fromTo(mc, 1, {x:0, alpha:1}, {x:100, alpha:0.5});

Keep in mind that you can chain these calls together and use other convenience methods like to(), call(), set(), staggerTo(), etc. to build out sequences very quickly:

//create a timeline that calls myFunction() when it completes
var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
//now we'll use chaining, but break each step onto a different line for readability...
tl.fromTo(mc, 1, {x:0}, {x:-100})    //tween mc.x from 0 to -100
  .to(mc, 1, {y:50}, "-=0.25")        //then tween mc.y to 50, starting it 0.25 seconds before the previous tween ends
  .set(mc, {alpha:0})            //then set mc.alpha to 0.5 immediately
  .call(otherFunction)            //then call otherFunction()
  .staggerTo([mc1, mc2, mc3], 1.5, {rotation:45}, 0.25); //finally tween the rotation of mc1, mc2, and mc3 to 45 and stagger the start times by 0.25 seconds

If you don't want to append the tween and would rather have precise control of the insertion point, you can use the additional position parameter. Or use a regular add() like myTimeline.add( TweenLite.fromTo(mc, 1, {x:0}, {x:100}), 2.75).

The 4th parameter is the position which controls the placement of the tween in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

tl.fromTo(mc, 1, {x:0}, {x:100});  //appends to the end of the timeline
tl.fromTo(mc, 1, {x:0}, {x:100}, 2);  //appends it at exactly 2 seconds into the timeline (absolute position)
tl.fromTo(mc, 1, {x:0}, {x:100}, "+=2");  //appends it 2 seconds after the end (with a gap of 2 seconds)
tl.fromTo(mc, 1, {x:0}, {x:100}, "myLabel");  //places it at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tween is inserted there)
tl.fromTo(mc, 1, {x:0}, {x:100}, "myLabel+=2");  //places it 2 seconds after "myLabel"

NOTE: 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 tweens actually begin.

Parameters

target:Object — Target object (or array of objects) whose properties the tween affects
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
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: myTimeline.fromTo(mc, 1, {x:0, y:0}, {x:100, y:200, onComplete:myFunction});
 
position:* (default = +=0) — Controls the placement of the tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

Returns
* — self (makes chaining easier)

See also

getChildren()method 
public function getChildren(nested:Boolean = true, tweens:Boolean = true, timelines:Boolean = true, ignoreBeforeTime:Number = -9999999999):Array

Returns an array containing all the tweens and/or timelines nested in this timeline. Callbacks (delayed calls) are considered zero-duration tweens.

Parameters

nested:Boolean (default = true) — Determines whether or not tweens and/or timelines that are inside nested timelines should be returned. If you only want the "top level" tweens/timelines, set this to false.
 
tweens:Boolean (default = true) — Determines whether or not tweens (TweenLite and TweenMax instances) should be included in the results
 
timelines:Boolean (default = true) — Determines whether or not timelines (TimelineLite and TimelineMax instances) should be included in the results
 
ignoreBeforeTime:Number (default = -9999999999) — All children with start times that are less than this value will be ignored.

Returns
Array — an Array containing the child tweens/timelines.
getLabelTime()method 
public function getLabelTime(label:String):Number

Returns the time associated with a particular label. If the label isn't found, -1 is returned.

Parameters

label:String — Label name

Returns
Number — Time associated with the label (or -1 if there is no such label)
getTweensOf()method 
public function getTweensOf(target:Object, nested:Boolean = true):Array

Returns the tweens of a particular object that are inside this timeline.

Parameters

target:Object — The target object of the tweens
 
nested:Boolean (default = true) — Determines whether or not tweens that are inside nested timelines should be returned. If you only want the "top level" tweens/timelines, set this to false.

Returns
Array — an Array of TweenLite and/or TweenMax instances
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)
remove()method 
public function remove(value:*):*

Removes a tween, timeline, callback, or label (or array of them) from the timeline.

Parameters

value:* — The tween, timeline, callback, or label that should be removed from the timeline (or an array of them)

Returns
* — self (makes chaining easier)
removeLabel()method 
public function removeLabel(label:String):*

Removes a label from the timeline and returns the time of that label. You could also use the remove() method to accomplish the same task.

Parameters

label:String — The name of the label to remove

Returns
* — Time associated with the label that was removed
seek()method 
override public function seek(position:*, suppressEvents:Boolean = true):*

Jumps to a specific time (or label) without affecting whether or not the instance is paused or reversed.

If there are any events/callbacks inbetween where the playhead was and the new time, they will not be triggered because by default suppressEvents (the 2nd parameter) is true. Think of it like picking the needle up on a record player and moving it to a new position before placing it back on the record. If, however, you do not want the events/callbacks suppressed during that initial move, simply set the suppressEvents parameter to false.

//jumps to exactly 2 seconds
myAnimation.seek(2);
 
//jumps to exactly 2 seconds but doesn't suppress events during the initial move:
myAnimation.seek(2, false);
//jumps to the "myLabel" label
myAnimation.seek("myLabel");
         

Parameters

position:* — The position to go to, described in any of the following ways: a numeric value indicates an absolute position, like 3 would be exactly 3 seconds from the beginning of the timeline. A string value can be either a label (i.e. "myLabel") or a relative value using the "+=" or "-=" prefixes like "-=2" (2 seconds before the end of the timeline) or a combination like "myLabel+=2" to indicate 2 seconds after "myLabel".
 
suppressEvents:Boolean (default = true) — If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter.

Returns
* — self (makes chaining easier)

See also

set()method 
public function set(target:Object, vars:Object, position:* = +=0):*

Adds a zero-duration tween to the end of the timeline (or elsewhere using the "position" parameter) that sets values immediately (when the virtual playhead reaches that position on the timeline) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.to(target, 0, {...}) ) but with less code. In other words, the following two lines produce identical results:

myTimeline.add( TweenLite.to(mc, 0, {x:100, alpha:0.5, immediateRender:false}) );
myTimeline.set(mc, {x:100, alpha:0.5});

Keep in mind that you can chain these calls together and use other convenience methods like to(), call(), fromTo(), staggerTo(), etc. to build out sequences very quickly:

//create a timeline that calls myFunction() when it completes
var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
//now we'll use chaining, but break each step onto a different line for readability...
tl.to(mc, 1, {x:100})    //tween mc.x to 100
  .set(mc, {alpha:0})    //then set mc.alpha to 0.5 immediately
  .to(mc, 1, {y:50})    //then tween mc.y to 50
  .call(otherFunction)    //then call otherFunction()
  .staggerTo([mc1, mc2, mc3], 1.5, {rotation:45}, 0.25); //finally tween the rotation of mc1, mc2, and mc3 to 45 and stagger the start times by 0.25 seconds

The 3rd parameter is the position which controls the placement of the tween in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

tl.set(mc, {x:100});  //appends to the end of the timeline
tl.set(mc, {x:100}, 2);  //appends it at exactly 2 seconds into the timeline (absolute position)
tl.set(mc, {x:100}, "+=2");  //appends it 2 seconds after the end (with a gap of 2 seconds)
tl.set(mc, {x:100}, "myLabel");  //places it at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tween is inserted there)
tl.set(mc, {x:100}, "myLabel+=2");  //places it 2 seconds after "myLabel"

Parameters

target:Object — Target object (or array of objects) whose properties will be set.
 
vars:Object — An object defining the value to which each property should be set. For example, to set mc.x to 100 and mc.y to 200, do this: myTimeline.set(mc, {x:100, y:200});
 
position:* (default = +=0) — Controls the placement of the zero-duration tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

Returns
* — self (makes chaining easier)

See also

shiftChildren()method 
public function shiftChildren(amount:Number, adjustLabels:Boolean = false, ignoreBeforeTime:Number = 0):*

Shifts the startTime of the timeline's children by a certain amount and optionally adjusts labels too. This can be useful when you want to prepend children or splice them into a certain spot, moving existing ones back to make room for the new ones.

Parameters

amount:Number — Number of seconds (or frames for frames-based timelines) to move each child.
 
adjustLabels:Boolean (default = false) — If true, the timing of all labels will be adjusted as well.
 
ignoreBeforeTime:Number (default = 0) — All children that begin at or after the startAtTime will be affected by the shift (the default is 0, causing all children to be affected). This provides an easy way to splice children into a certain spot on the timeline, pushing only the children after that point back to make room.

Returns
* — self (makes chaining easier)
staggerFrom()method 
public function staggerFrom(targets:Array, duration:Number, vars:Object, stagger:Number = 0, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*

Tweens an array of targets from a common set of destination values (using the current values as the destination), but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code. For example, let's say you have an array containing references to a bunch of text fields that you'd like to drop into place while fading in, all in a staggered fashion with 0.2 seconds between each tween's start time:

var textFields = [tf1, tf2, tf3, tf4, tf5];
myTimeline.staggerFrom(textFields, 1, {y:"+=150"}, 0.2);

staggerFrom() simply loops through the targets array and creates a from() tween for each object and then inserts it at the appropriate place on a new TimelineLite instance whose onComplete corresponds to the onCompleteAll (if you define one) and then appends that TimelineLite to the timeline (as a nested child).

Note that if you define an onComplete (or any callback for that matter) in the vars parameter, it will be called for each tween rather than the whole sequence. This can be very useful, but if you want to call a function after the entire sequence of tweens has completed, use the onCompleteAll parameter (the 6th parameter).

The 5th parameter is the position which controls the placement of the tweens in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the first tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the first tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the first tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tweens there which can be quite convenient.

tl.staggerFrom(myArray, 1, {x:100}, 0.25);  //appends to the end of the timeline
tl.staggerFrom(myArray, 1, {x:100}, 0.25, 2);  //appends at exactly 2 seconds into the timeline (absolute position)
tl.staggerFrom(myArray, 1, {x:100}, 0.25, "+=2");  //appends 2 seconds after the end (with a gap of 2 seconds)
tl.staggerFrom(myArray, 1, {x:100}, 0.25, "myLabel");  //places at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tweens are inserted there)
tl.staggerFrom(myArray, 1, {x:100}, 0.25, "myLabel+=2");  //places 2 seconds after "myLabel"

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.

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 accept an extra (8th) parameter for onCompleteAllScope.

Parameters

targets:Array — An array of target objects whose properties should be affected
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
vars:Object — An object defining the beginning value for each property that should be tweened as well as any special properties like ease. For example, to tween x from 100 and y from 200 for mc1, mc2, and mc3, staggering their start time by 0.25 seconds and then call myFunction when they last one has finished, do this: myTimeline.staggerFrom([mc1, mc2, mc3], 1, {x:100, y:200}, 0.25, 0, null, myFunction}).
 
stagger:Number (default = 0) — Amount of time in seconds (or frames if the timeline is frames-based) to stagger the start time of each tween. For example, you might want to have 5 objects move down 100 pixels while fading out, and stagger the start times by 0.2 seconds - you could do: myTimeline.staggerTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"+=100", alpha:0}, 0.2).
 
position:* (default = +=0) — Controls the placement of the first tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.
 
onCompleteAll:Function (default = null) — A function to call as soon as the entire sequence of tweens has completed
 
onCompleteAllParams:Array (default = null) — An array of parameters to pass the onCompleteAll method.

Returns
* — self (makes chaining easier)

See also

staggerFromTo()method 
public function staggerFromTo(targets:Array, duration:Number, fromVars:Object, toVars:Object, stagger:Number = 0, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*

Tweens an array of targets from and to a common set of values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code. For example, let's say you have an array containing references to a bunch of text fields that you'd like to fade from alpha:1 to alpha:0 in a staggered fashion with 0.2 seconds between each tween's start time:

var textFields = [tf1, tf2, tf3, tf4, tf5];
myTimeline.staggerFromTo(textFields, 1, {alpha:1}, {alpha:0}, 0.2);

staggerFromTo() simply loops through the targets array and creates a fromTo() tween for each object and then inserts it at the appropriate place on a new TimelineLite instance whose onComplete corresponds to the onCompleteAll (if you define one) and then appends that TimelineLite to the timeline (as a nested child).

Note that if you define an onComplete (or any callback for that matter) in the vars parameter, it will be called for each tween rather than the whole sequence. This can be very useful, but if you want to call a function after the entire sequence of tweens has completed, use the onCompleteAll parameter (the 7th parameter).

The 6th parameter is the position which controls the placement of the tweens in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the first tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the first tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the first tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tweens there which can be quite convenient.

tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25);  //appends to the end of the timeline
tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25, 2);  //appends at exactly 2 seconds into the timeline (absolute position)
tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25, "+=2");  //appends 2 seconds after the end (with a gap of 2 seconds)
tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25, "myLabel");  //places at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tweens are inserted there)
tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25, "myLabel+=2");  //places 2 seconds after "myLabel"

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 accept an extra (9th) parameter for onCompleteAllScope.

Parameters

targets:Array — An array of target objects whose properties should be affected
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
fromVars:Object — An object defining the starting value for each property that should be tweened. For example, to tween x from 100 and 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 ease. For example, to tween x from 0 to 100 and y from 0 to 200, staggering the start times by 0.2 seconds and then call myFunction when they all complete, do this: myTimeline.staggerFromTo([mc1, mc2, mc3], 1, {x:0, y:0}, {x:100, y:200}, 0.2, 0, null, myFunction});
 
stagger:Number (default = 0) — Amount of time in seconds (or frames if the timeline is frames-based) to stagger the start time of each tween. For example, you might want to have 5 objects move down 100 pixels while fading out, and stagger the start times by 0.2 seconds - you could do: myTimeline.staggerTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"+=100", alpha:0}, 0.2).
 
position:* (default = +=0) — Controls the placement of the first tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.
 
onCompleteAll:Function (default = null) — A function to call as soon as the entire sequence of tweens has completed
 
onCompleteAllParams:Array (default = null) — An array of parameters to pass the onCompleteAll method.

Returns
* — self (makes chaining easier)

See also

staggerTo()method 
public function staggerTo(targets:Array, duration:Number, vars:Object, stagger:Number, position:* = +=0, onCompleteAll:Function = null, onCompleteAllParams:Array = null):*

Tweens an array of targets to a common set of destination values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly small amount of code. For example, let's say you have an array containing references to a bunch of text fields that you'd like to fall away and fade out in a staggered fashion with 0.2 seconds between each tween's start time:

var textFields = [tf1, tf2, tf3, tf4, tf5];
myTimeline.staggerTo(textFields, 1, {y:"+=150", ease:Cubic.easeIn}, 0.2);

staggerTo() simply loops through the targets array and creates a to() tween for each object and then inserts it at the appropriate place on a new TimelineLite instance whose onComplete corresponds to the onCompleteAll (if you define one) and then appends that TimelineLite to the timeline (as a nested child).

Note that if you define an onComplete (or any callback for that matter) in the vars parameter, it will be called for each tween rather than the whole sequence. This can be very useful, but if you want to call a function after the entire sequence of tweens has completed, use the onCompleteAll parameter (the 6th parameter).

The 5th parameter is the position which controls the placement of the tweens in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the first tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the first tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the first tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tweens there which can be quite convenient.

tl.staggerTo(myArray, 1, {x:100}, 0.25);  //appends to the end of the timeline
tl.staggerTo(myArray, 1, {x:100}, 0.25, 2);  //appends at exactly 2 seconds into the timeline (absolute position)
tl.staggerTo(myArray, 1, {x:100}, 0.25, "+=2");  //appends 2 seconds after the end (with a gap of 2 seconds)
tl.staggerTo(myArray, 1, {x:100}, 0.25, "myLabel");  //places at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tweens are inserted there)
tl.staggerTo(myArray, 1, {x:100}, 0.25, "myLabel+=2");  //places 2 seconds after "myLabel"

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 accept an extra (8th) parameter for onCompleteAllScope.

Parameters

targets:Array — An array of target objects whose properties should be affected
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
vars:Object — An object defining the end value for each property that should be tweened as well as any special properties like ease. For example, to tween x to 100 and y to 200 for mc1, mc2, and mc3, staggering their start time by 0.25 seconds and then call myFunction when they last one has finished, do this: myTimeline.staggerTo([mc1, mc2, mc3], 1, {x:100, y:200}, 0.25, 0, null, myFunction}).
 
stagger:Number — Amount of time in seconds (or frames if the timeline is frames-based) to stagger the start time of each tween. For example, you might want to have 5 objects move down 100 pixels while fading out, and stagger the start times by 0.2 seconds - you could do: myTimeline.staggerTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"+=100", alpha:0}, 0.2).
 
position:* (default = +=0) — Controls the placement of the first tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.
 
onCompleteAll:Function (default = null) — A function to call as soon as the entire sequence of tweens has completed
 
onCompleteAllParams:Array (default = null) — An array of parameters to pass the onCompleteAll method.

Returns
* — self (makes chaining easier)

See also

stop()method 
public function stop():*

[deprecated] Pauses the timeline (used for consistency with Flash's MovieClip.stop() functionality, but essentially accomplishes the same thing as pause() without the parameter)

Returns
* — self (makes chaining easier)
to()method 
public function to(target:Object, duration:Number, vars:Object, position:* = +=0):*

Adds a TweenLite.to() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.to(...) ) but with less code. In other words, the following two lines produce identical results:

myTimeline.add( TweenLite.to(mc, 1, {x:100, alpha:0.5}) );
myTimeline.to(mc, 1, {x:100, alpha:0.5});

Keep in mind that you can chain these calls together and use other convenience methods like fromTo(), call(), set(), staggerTo(), etc. to build out sequences very quickly:

//create a timeline that calls myFunction() when it completes
var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
//now we'll use chaining, but break each step onto a different line for readability...
tl.to(mc, 1, {x:100})        //tween mc.x to 100
  .to(mc, 1, {y:50}, "-=0.25")    //then tween mc.y to 50, starting the tween 0.25 seconds before the previous one ends
  .set(mc, {alpha:0})        //then set mc.alpha to 0.5 immediately
  .call(otherFunction)        //then call otherFunction()
  .staggerTo([mc1, mc2, mc3], 1.5, {rotation:45}, 0.25); //finally tween the rotation of mc1, mc2, and mc3 to 45 and stagger the start times by 0.25 seconds

If you don't want to append the tween and would rather have precise control of the insertion point, you can use the additional position parameter. Or use a regular add() like myTimeline.add( TweenLite.to(mc, 1, {x:100}), 2.75).

The 4th parameter is the position which controls the placement of the tween in the timeline (by default, it's at the end of the timeline). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween which can be quite convenient.

tl.to(mc, 1, {x:100});  //appends to the end of the timeline
tl.to(mc, 1, {x:100}, 2);  //appends it at exactly 2 seconds into the timeline (absolute position)
tl.to(mc, 1, {x:100}, "+=2");  //appends it 2 seconds after the end (with a gap of 2 seconds)
tl.to(mc, 1, {x:100}, "myLabel");  //places it at "myLabel" (and if "myLabel" doesn't exist yet, it's added to the end and then the tween is inserted there)
tl.to(mc, 1, {x:100}, "myLabel+=2");  //places it 2 seconds after "myLabel"

Parameters

target:Object — Target object (or array of objects) whose properties the tween affects
 
duration:Number — Duration in seconds (or frames if the timeline is frames-based)
 
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: myTimeline.to(mc, 1, {x:100, y:200, onComplete:myFunction}).
 
position:* (default = +=0) — Controls the placement of the tween in the timeline (by default, it's the end of the timeline, like "+=0"). Use a number to indicate an absolute time in terms of seconds (or frames for frames-based timelines), or you can use a string with a "+=" or "-=" prefix to offset the insertion point relative to the END of the timeline. For example, "+=2" would place the tween 2 seconds after the end, leaving a 2-second gap. "-=2" would create a 2-second overlap. You may also use a label like "myLabel" to have the tween inserted exactly at the label or combine a label and a relative offset like "myLabel+=2" to insert the tween 2 seconds after "myLabel" or "myLabel-=3" to insert it 3 seconds before "myLabel". If you define a label that doesn't exist yet, it will automatically be added to the end of the timeline before inserting the tween there which can be quite convenient.

Returns
* — self (makes chaining easier)

See also

totalDuration()method 
override public function totalDuration(value:Number):*

Gets the timeline's total duration or, if used as a setter, adjusts the timeline's timeScale to fit it within the specified duration. For example, if a TimelineMax instance has a duration of 2 and a repeat of 3, its totalDuration would be 8 (one standard play plus 3 repeats equals 4 total cycles).

Due to the fact that a timeline's totalDuration is dictated by its contents, using this method as a setter will simply cause the timeScale to be adjusted to fit the current contents into the specified totalDuration. For example, if there are 20-seconds worth of tweens in the timeline and you do myTimeline.totalDuration(10), the timeScale would be changed to 2. If you checked the totalDuration again immediately after that, it would still return 20 because technically that is how long all the child tweens/timelines are but upon playback the speed would be doubled because of the timeScale.

This method serves as both a getter and setter. Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining, like myAnimation.totalDuration(2).play(1);

var ctd = myAnimation.totalDuration(); //gets current total duration
myAnimation.totalDuration( 20 ); //adjusts the timeScale so that myAnimation fits into exactly 20 seconds on its parent timeline

Parameters

value:Number (default = NaN) — Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

Returns
* — Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

See also

usesFrames()method 
public function usesFrames():Boolean

[READ-ONLY] If true, the timeline's timing mode is frames-based instead of seconds. This can only be set to true by passing useFrames:true in the vars parameter of the constructor, or by nesting this timeline in another whose timing mode is frames-based. An animation's timing mode is always determined by its parent timeline).

Returns
Boolean