With a few other fixes I was able to get the VanishingCircles demo, that
I am using in the Pro JavaFX book update, working. The code is pretty
short [1/4 the character count of the Java version], but it does a lot:
var circles:Circle[];
Stage {
title: "Vanishing Circles"
Scene {
width: 800
height: 600
fill: BLACK
Group {
circles = for (i in [1..50]) {
def c:Circle = Circle {
centerX: random() * 800
centerY: random() * 600
radius: 150
fill: color(random(), random(), random(), .2)
effect: BoxBlur {
height: 10
width: 10
iterations: 3
}
stroke: WHITE
strokeWidth: bind if (c.hover) 5 else 0
onMouseClicked: function(e) {
Timeline {at (3s) {c.radius => 0}}.play()
}
}
}
}
}
}
Timeline {
for (circle in circles) at (40s) {
circle.centerX => random() * 800;
circle.centerY => random() * 600
}
}.play()
Give it a try and let me know what you think.
P.S.: On a side note, I have started down the dark path of implementing
object literal and binding support directly against JavaFX 2.0
libraries. It has turned out to be a challenging implementation, but if
I can get this done it will mean you can code directly against the
JavaFX 2.0 Java APIs without a wrapper layer in the middle (better
performance, solves the bind listener problem, no need to update our
APIs each version, etc.)
Cheers,
--
--Steve
blog: http://steveonjava.com/