Timeline Class
The Timeline class synchronizes multiple tweens and allows them to be controlled as a group. Please note that if a timeline is looping, the tweens on it may appear to loop even if the "loop" property of the tween is false.
Constructor
Timeline
-
tweens
-
labels
-
props
Parameters:
-
tweens
ObjectAn array of Tweens to add to this timeline. See addTween for more info.
-
labels
#crossLink "Timeline/setLabels"An object defining labels for using gotoAndPlay/Stop. See }{{/crossLink}} for details.
-
props
Loop:trueThe 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.
Item Index
Methods
Methods
_goto
()
protected
addLabel
-
label
-
position
Adds a label that can be used with gotoAndPlay/Stop.
addLabel
-
o
Defines labels for use with gotoAndPlay/Stop. Overwrites any previously set labels.
Parameters:
-
o
LabelName:timeAn object defining labels for using gotoAndPlay/Stop in the form where time is in ms (or ticks if useTicks is true).
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
ObjectThe tween(s) to add. Accepts multiple arguments.
Returns:
clone
()
protected
gotoAndPlay
-
positionOrLabel
Unpauses this timeline and jumps to the specified position or label.
Parameters:
-
positionOrLabel
ObjectThe position in milliseconds (or ticks if useTicks is true) or label to jump to.
gotoAndStop
-
positionOrLabel
Pauses this timeline and jumps to the specified position or label.
Parameters:
-
positionOrLabel
ObjectThe position in milliseconds (or ticks if useTicks is true) or label to jump to.
initialize
()
protected
Initialization method.
removeTween
-
tween
Removes one or more tweens from this timeline.
Parameters:
-
tween
ObjectThe tween(s) to remove. Accepts multiple arguments.
Returns:
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
ObjectA numeric position value or label string.
setPaused
-
value
Pauses or plays this timeline.
Parameters:
-
value
ObjectIndicates whether the tween should be paused (true) or played (false).
setPosition
-
value
-
actionsMode
Advances the timeline to the specified position.
Parameters:
Returns:
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
ObjectThe time to advance in milliseconds (or ticks if useTicks is true).
toString
()
String
Returns a string representation of this object.
Returns:
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.
Properties
_labels
ArrayString
protected
_tweens
ArrayTween
protected
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.
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.