Java Reference
In-Depth Information
How to do it...
The next code snippet illustrates how to use data binding in keyframe-based animation. We
will animate several objects synchronously using only one timeline. You can see the full code
in ch03/source-code/src/animation/BoundAnimationDemo.fx .
def w = 400;
def h = 200;
def width = 50;
def rad = width/2;
def spacer = 30;
var locY = h - width;
def circ1 = Circle {
centerX: rad + spacer centerY: bind (locY + rad)
radius: rad
}
def rec1 = Rectangle {
x: circ1.boundsInLocal.maxX + spacer y: bind locY
width:width height:width
}
def circ2 = Circle {
centerX: rec1.boundsInLocal.maxX + spacer + rad
centerY: bind (locY + rad) radius: rad
}
def rec2 = Rectangle {
x: circ2.boundsInLocal.maxX + spacer y: bind locY
width:width height:width
}
Timeline {
repeatCount:Timeline.INDEFINITE
autoReverse:true
keyFrames:[
at(1s){locY => width tween Interpolator.EASEBOTH}
]
}.play();
 
Search WWH ::




Custom Search