package timelineproblem; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.shape.Rectangle; import javafx.scene.paint.Color; import javafx.animation.Timeline; import javafx.animation.KeyFrame; import javafx.scene.input.MouseEvent; import javafx.scene.text.Text; import javafx.scene.text.Font; var t1:Time= Time{}; var t2:Time= Time{}; t2.translateY = 50; var t = Timeline { repeatCount: 1 keyFrames: [ KeyFrame { time:1s action: function(){ t1.t.playFromStart(); } }, KeyFrame { time:2s action: function(){ t2.t.playFromStart(); } }, ] } Stage { title: "Timeline in Sequence" width: 400 height: 400 scene: Scene { content: [ t1,t2, Rectangle { onMouseClicked: function( e: MouseEvent ):Void { t.playFromStart(); } x: 180, y: 200 width: 80 height: 30 fill: Color.GRAY stroke: Color.BLACK }, Text { fill: Color.WHITE font: Font { size: 15 name:"Arial Bold" } x: 205, y: 220 content: "Run" } ] } }