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 elapsed. A Timeline
with indefinite duration (a repeatCount
of INDEFINITE) runs repeatedly until the stop() method
is explicitly called, which will stop the running
Timeline
and reset its play head to the initial position.
Timeline
can be paused by calling pause(), and next play()
call will resume the Timeline
from where it was paused.
A Timeline
's play head can be randomly positioned, whether it is running or
not. If the Timeline
is running, the play head 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
Script Variable Summary
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | INDEFINITE | Integer |
Used to specify an animation that repeats indefinitely, until
the |
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-read protected | cycleDuration | Duration | subclass | subclass | 0ms |
Read-only variable to indicate the duration of one cycle of this
Read-only variable to indicate the duration of one cycle of this
This is set to the largest time value of its keyFrames. 0msProfile: common |
|
public-init | framerate | Number |
The maximum framerate at which this animation will run, in frames per second. The maximum framerate at which this animation will run, in frames per second. This can be used, for example, to keep particularly complex Timelines from over-consuming system resources. By default, a Timeline's framerate is not explicitly limited, meaning the Timeline will run at an optimal framerate for the underlying platform. Profile: common |
||||
public | interpolate | Boolean | true |
Enable/disable interpolation. |
|||
public | keyFrames | KeyFrame[] |
Defines the sequence of Defines the sequence of
See Also:
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
If
Note that Profile: common |
||||
public | time | Duration | 0ms |
Defines the Defines the
If
If user wants to bind the variable and update it simultaneously, bidirectional
Profile: common |
|||
public-read | totalDuration | Duration | 0ms |
Read-only variable to indicate the total duration of this
Read-only variable to indicate the total duration of this
This is set to cycleDuration * repeatCount. 0msProfile: common |
Inherited Variables
Function Summary
- public evaluateKeyValues() : Void
-
Instructs the
Timeline
to evaluate allKeyValue.value()
s in the Timeline.Instructs the
Timeline
to evaluate allKeyValue.value()
s in the Timeline.See Also:
KeyFrame.valuesProfile: common
- 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 the play head 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.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.Profile: common
- public stop() : Void