Java Reference
In-Depth Information
KeyFrame {
time:
duration
values: [
x => 1000 tween Interpolator.LINEAR,
y => 1000 tween Interpolator.LINEAR,
]
}
]
}
Now, if the application needs to change the duration of the timeline, one merely
has to change the
duration
variable to a new duration. Please note that it is
important to declare the
duration
variable before the timeline is declared.
Key values are declared using a special syntax:
target
=>
value
tween
interpolator
Target
is the target variable that will be changed,
value
is the target value that
the target variable assumes when the key frame time arrives, and
interpolator
is the
Interpolator
to use. So in the preceding example, the
x
variable is zero at
0 seconds, and then 1000 at 10 seconds. This value uses a
linear
, or constant rate
of change, interpolator over the 10-second interval. The
=>
operator indicates
that the variable will transition to the value during the time slice. The
tween
key-
word identifies the
Interpolator
to use during tweening. If no
tween
and
interpolator
is given, a discrete interpolator is the default. This means the
value instantly changes from 0 to 1000 when the key frame's time is reached.
The class,
javafx.animation.KeyFrame
,
represents a key frame within the
timeline. Each key frame has a time in the form of a duration, zero or more key
values, an optional action function that is executed when the play arrives at the
key frame's time, and zero or more sub timelines that start to play when the key
frame's time is reached.
As previously mentioned, there are two ways to declare a key frame. One way is
to use the normal JavaFX object literal syntax for the
KeyFrame
object.
Search WWH ::
Custom Search