Overview
An animation is driven by its associated properties, such as size, location
and color, etc. Timeline
provides the capability to update
the property values along the progression of time.
A Timeline
, defined by one or more KeyFrames, processes
individual KeyFrame sequentially, in the order specified by
KeyFrame.time
. The animated properties, defined as key
values in KeyFrame.values
, are interpolated (when interpolation is enabled)
to/from the targeted key values at the specified time of the KeyFrame to
Timeline
's initial position, depends on Timeline
's direction.
Timeline
processes individual KeyFrame
at or after specified
time interval elapsed, it does not guarantee the timing when KeyFrame
is processed.
Call play() or playFromStart() to play a Timeline
.
The Timeline
progresses in the direction and speed specified by
rate, and stops when its duration is elasped. Timeline
with indefinite duration, defined as a Timeline
has repeatCount
= INDEFINITE or a Timeline
contains such sub timeline, runs
forever, until explicit stop() is called, which will stop the running
Timeline
and reset its playhead to initial position.
Timeline
can be paused by calling pause(), and next play()
call will resume the Timeline
from where it was paused.
Timeline
's playhead can be randomly positioned, no matter it is running or
not. If the Timeline
is running, the playhead jumps to the specified
position immediately and continues playing from new position. If the Timeline
is not running, the next play() will start the Timeline
from the
specified position.
Invert the value of rate can invert Timeline
play direction. Inverting
a running Timeline
causes it to reverse direction in play and play back
over the portion it has elapsed.
See Also:
KeyFrame
Profile: common
Variable Summary
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | autoReverse | Boolean | false |
Defines whether this animation reverses direction on alternating cycles. Defines whether this animation reverses direction on alternating
cycles.
If Profile: common |
|||
public-read | currentRate | Number | 0.0 |
Read-only variable to indicate current direction/speed at which the
Read-only variable to indicate current direction/speed at which the
Profile: common |
|||
public-init | framerate | Number |
The maximum framerate at which this animation will run, in frames per second. |
||||
public | INDEFINITE | Integer |
Used to specify an animation that repeats indefinitely (until
the |
||||
public | interpolate | Boolean | true |
Enable/disable interpolation. |
|||
public | keyFrames | KeyFrame[] |
Defines the sequence of Defines the sequence of Profile: common |
||||
public-read | paused | Boolean |
Read-only var that indicates whether the animation is currently paused. Read-only var that indicates whether the animation is currently paused.
This value is initially
Note that Profile: common |
||||
public | rate | Number | 1.0 |
Defines the direction/speed at which the Defines the direction/speed at which the
The absolute value of
Rate
Inverting the rate of a running Profile: common |
|||
public | repeatCount | Number | 1.0 |
Defines the number of cycles in this animation. Defines the number of cycles in this animation.
The Profile: common |
|||
public-read | running | Boolean |
Read-only var that indicates whether the animation is currently running. Read-only var that indicates whether the animation is currently running.
This value is initially
Note that Profile: common |
||||
public | time | Duration | 0.0ms |
Defines Defines
If
If user wants to bind the variable and update it simultaneously, bidirectional
Changes Profile: common |
Inherited Variables
Function Summary
- public pause() : Void
- public play() : Void
-
Plays
Timeline
from current position in the direction indicated byrate
.Plays
Timeline
from current position in the direction indicated byrate
. If the timeline is running, it has no effect.When
rate
> 0 (forward play), if aTimeline
is already positioned at the end, the first cycle will not be played, it is considered to have already finished. This also applies to a backward (rate
< 0) cycle if a timeline is positioned at the beginning. However, if theTimeline
hasrepeatCount
> 1, following cycle(s) will be played as usual.When
Timeline
reaches the end,Timeline
is stopped and playhead remains at the end.To play a
Timeline
backwards from the end:
timeline.rate = negative rate
timeline.time = overall duration of timeline
timeline.play()
Note:
play()
is an asynchronous call,Timeline
may not start immediately.- It has no effect on sub timelines.
Profile: common
- public playFromStart() : Void
-
Plays timeline from initial position in forward direction.
Plays timeline from initial position in forward direction.
It is equivalent to
timeline.stop();
timeline.rate = Math.abs(timeline.rate); timeline.time = 0.0s;
timeline.play();
Note:
playFromStart()
is an asynchronous call,Timeline
may not start immediately.- It has no effect on sub timelines.
Profile: common
- public stop() : Void
-
Stops the animation and resets playhead to initial position.
Stops the animation and resets playhead to initial position. If the animation is not currently running, this method has no effect.
Note:
stop()
is an asynchronous call, timeline may not stop immediately.- It has no effect on sub timelines.
Profile: common