TweenJS

TweenJS  0.3.0

TweenJS > TweenJS > Timeline
Search:
 
Filters

Class Timeline

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

Constructor

Timeline ( tweens , labels , props )
Parameters:
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.

Properties

_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.

Methods

_goto

protected void _goto ( )
Returns: void

addLabel

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

addTween

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.
Parameters:
tween <object> The tween(s) to add. Accepts multiple arguments.

clone

protected void clone ( )
Returns: void

gotoAndPlay

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

gotoAndStop

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

initialize

protected void initialize ( )
Initialization method.
Returns: void

removeTween

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

resolve

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.
Parameters:
positionOrLabel <object> A numeric position value or label string.
Returns: void

setPaused

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

setPosition

setPosition ( value , actionsMode )
Advances the timeline to the specified position.
Parameters:
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.

tick

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.
Parameters:
delta <object> The time to advance in milliseconds (or ticks if useTicks is true).
Returns: void

toString

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

updateDuration

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