Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created January 16, 2010 17:46
Show Gist options
  • Save bluepapa32/278915 to your computer and use it in GitHub Desktop.
Save bluepapa32/278915 to your computer and use it in GitHub Desktop.
How to use FadeTransition
import javafx.animation.*;
import javafx.animation.transition.*;
import javafx.scene.*;
import javafx.scene.image.*;
import javafx.scene.layout.*;
import javafx.scene.shape.*;
import javafx.stage.*;
public function run(args: String[]) {
var node = ImageView {
image: Image { url: args[0] }
};
var t: Transition = FadeTransition {
node: node
duration: 0.5s
fromValue: 1.0
toValue: 0.0
action: function() {
node.visible = not node.visible;
}
override function play() {
t.rate = if (node.visible) 1 else -1;
super.play();
}
}
Stage {
scene: Scene {
content: Stack {
content: [
Rectangle {
width: 300
height: 300
onMouseClicked: function(e) {
if (not t.running) {
t.play();
}
}
}
node
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment