Keep your FX Code Clean (My version)
Posted by rbair on March 24, 2009 at 2:54 PM EDT
The Exploding Pixels blog has an entry on clean FX code formatting. I didn't really like the options provided so far, so I decided to write a quick blog with my version.
def backgroundImage = Image { url: "{__DIR__}background.png" };
var verticalPositionOfLine:Number;
var s = Stage {
title: "Background Image"
scene: Scene {
width: 200
height: 232
content: [
ImageView { image: backgroundImage },
// Paints two moving lines
Group {
translateY: bind verticalPositionOfLine
content: [
Line { startX:0, startY:20, endX:200, endY:0, stroke:Color.RED }
Line { startX:0, startY:30, endX:200, endY:10, stroke:Color.RED }
]
}
]
}
}
// Start the line animation
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames: [
at (0s) { verticalPositionOfLine => -20 }
at (3s) { verticalPositionOfLine => 200 tween Interpolator.LINEAR }
}
}.play();
s
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- rbair's blog
- 1460 reads






Comments
by kennethorr - 2009-03-24 13:07
Nice...I think your version of the code is quite readable. -Ken