TweenJS  0.3.0

TweenJS > TweenJS > Timeline

Class Timeline

The Timeline class synchronizes multiple tweens and allows them to be controlled as a group.


Timeline ( tweens , labels , props )
tweens <object> An array of Tweens to add to this timeline. See addTween for more info.
labels <object> An object defining labels for using gotoAndPlay/Stop. See setLabels for details.
props <loop:true> The configuration properties to apply to this tween instance (ex. ). All properties default to false. Supported props are:
  • loop: sets the loop property on this tween.
  • useTicks: uses ticks for all durations instead of milliseconds.
  • ignoreGlobalPause: sets the ignoreGlobalPause property on this tween.
  • paused: indicates whether to start the tween paused.
  • position: indicates the initial position for this timeline.
  • onChanged: specifies an onChange handler for this timeline.


_labels - protected Array[String]

_paused - protected Boolean

_prevPos - protected Number

_prevPosition - protected Number

_tweens - protected Array[Tween]

_useTicks - protected Boolean

duration - Number

Read-only property specifying the total duration of this timeline in milliseconds (or ticks if useTicks is true). This value is usually automatically updated as you modify the timeline. See updateDuration for more information.

ignoreGlobalPause - Boolean

Causes this timeline to continue playing when a global pause is active.

loop - Boolean

If true, the timeline will loop when it reaches the end. Can be set via the props param.

onChange - Function

Called, with a single parameter referencing this timeline instance, whenever the timeline's position changes.

position - Object

Read-only. The current normalized position of the timeline. This will always be a value between 0 and duration. Changing this property directly will have no effect.



protected void _goto ( )
Returns: void


void addLabel ( label , position )
Adds a label that can be used with gotoAndPlay/Stop.
label <object> The label name.
position <object> The position this label represents.
Returns: void


addTween ( tween )
Adds one or more tweens (or timelines) to this timeline. The tweens will be paused (to remove them from the normal ticking system) and managed by this timeline. Adding a tween to multiple timelines will result in unexpected behaviour.
tween <object> The tween(s) to add. Accepts multiple arguments.


protected void clone ( )
Returns: void


void gotoAndPlay ( positionOrLabel )
Unpauses this timeline and jumps to the specified position or label.
positionOrLabel <object> The position in milliseconds (or ticks if useTicks is true) or label to jump to.
Returns: void


void gotoAndStop ( positionOrLabel )
Pauses this timeline and jumps to the specified position or label.
positionOrLabel <object> The position in milliseconds (or ticks if useTicks is true) or label to jump to.
Returns: void


protected void initialize ( )
Initialization method.
Returns: void


removeTween ( tween )
Removes one or more tweens from this timeline.
tween <object> The tween(s) to remove. Accepts multiple arguments.


void resolve ( positionOrLabel )
If a numeric position is passed, it is returned unchanged. If a string is passed, the position of the corresponding frame label will be returned, or null if a matching label is not defined.
positionOrLabel <object> A numeric position value or label string.
Returns: void


void setPaused ( value )
Pauses or plays this timeline.
value <object> Indicates whether the tween should be paused (true) or played (false).
Returns: void


setPosition ( value , actionsMode )
Advances the timeline to the specified position.
value <object> The position to seek to in milliseconds (or ticks if useTicks is true).
actionsMode <object> Optional parameter specifying how actions are handled. See Tween.setPosition for more details.


void tick ( delta )
Advances this timeline by the specified amount of time in milliseconds (or ticks if useTicks is true). This is normally called automatically by the Tween engine (via Tween.tick), but is exposed for advanced uses.
delta <object> The time to advance in milliseconds (or ticks if useTicks is true).
Returns: void


String toString ( )
Returns a string representation of this object.
Returns: String
a string representation of the instance.


void updateDuration ( )
Recalculates the duration of the timeline. The duration is automatically updated when tweens are added or removed, but this method is useful if you modify a tween after it was added to the timeline.
Returns: void