Created
January 16, 2010 17:46
-
-
Save bluepapa32/278915 to your computer and use it in GitHub Desktop.
How to use FadeTransition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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