Java Reference
In-Depth Information
F Interpolator.LINEAR —maintains constant progression from the beginning to the
end of the sequence (default)
F Interpolator.DISCRETE —this interpolator does no in-between animation
You can also create your own custom interpolator to specify how animated objects
behave during animation. See the recipe Creating custom interpolators for animation
in the next section.
Using the Timeline class as a timer
You can use the Timeline class to create general-purpose timers for your code. Declare an
instance of the Timeline class having a single KeyFrame with the following:
F Set the keyframe's time property as the timer's time period.
F Define a callback function for the action property. It will be invoked on each
expiration of the time period.
F Set the Timeline's repeatCount to INDEFINITE and turn off interpolation
( interpolate=false ) for discrete time progression.
The following snippet shows an example of how this would work (see full listing at ch03/
source-code/src/animation/TimelineTimerDemo.fx ).
var counter = 0;
var timer = Timeline {
repeatCount: Timeline.INDEFINITE
interpolate: false
keyFrames: [
KeyFrame {
time: 1s
action: function (): Void {
println(counter++);
}
}
]
}
timer.play();
The timer starts when timer.play() is invoked. The timer will run continuously until either
the pause() or the stop() method is invoked.
See also
F Introduction
F Creating simple animation with the Transition API
F Composing animation with the Transition API
F Creating custom interpolators for animation
 
Search WWH ::




Custom Search