Java Reference
In-Depth Information
autoReverse
is set to true, you can determine whether the timeline is currently
playing forward or backward from the
currentRate
value. To set the play rate,
use the
rate
instance variable. Again, if the
rate
is negative, the timeline will
play in reverse.
You can tell the current instant of playback using the
time
instance variable.
Also use this instance variable to set the specific time to resume play. If you want
to resume play halfway through the time sequence, then you can set the
time
value to one half the total duration. Then when you instruct the timeline to play,
it will play from that point. Another way to use the
time
variable is to increment
the time to jump forward or decrement it to jump backward in the animation. For
example, if you define a button to skip forward 10 seconds, you can increment
the time by 10 seconds or actually by 10,000 milliseconds. To set the timeline to
the beginning, you can set the
time
variable to zero (0). To set it to the end, set
the
time
variable to the end duration for the timeline. This is useful if you want
to play the timeline in reverse from the end.
The instance variable,
interpolate
, is by default set to true and means that
when the timeline plays, the system will split up the interval between time
frames and invoke the key target value interpolators. If the timeline is not using
interpolations, but perhaps only uses actions, there may be a performance
improvement to set
interpolate
to false. This is because when
interpolate
is
false, the timeline does not have to do the tweening steps between key frames.
A key frame defines a pivotal timing event with values that are tweened, or inter-
polated, along the timeline. The key frame contains a time value within the time-
line, along with optional items. These items are associated target values called
key values, an
action
that is executed when the time is reached within a play, or a
sub timeline that starts when the key frame's time within the timeline is reached.
There is also an indicator identifying whether the action function can be skipped
if the timeline is running behind schedule.
A
KeyFrame
may be defined using the object literal syntax for creating any JavaFX
object, or may use a special short-cut syntax. First, let us cover a few basics.
A
javafx.lang.Duration
is an object that defines a time interval. To simplify
creating durations, JavaFX supports
time literals
. In the previous timeline example,
Search WWH ::
Custom Search