1
我的PathTransition動畫幾個標籤,並有一個setOnFinished-事件。當用光標輸入標籤時,該標籤會生成動畫並停止前一個標籤的動畫(如果有)。如何在javafx 2.4.0中停止轉換後觸發事件?
Label l1 = new Label("Hello");
Label l2 = new Label("Hello");
Path path = new Path();
path.getElements().add(new MoveTo(100,100);
path.getElements().add(new LineTo(200,200));
PathTransition pathTransition = new PathTransition();
pathTransition.setDuration(Duration.millis(1000));
pathTransition.setPath(path);
pathTransition.setNode(l1);
pathTransition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// do something
}
});
pathTransition.play()
// if i enter l2 i want stop the l1 animation
pathTransition.stop()
// animate the l2
// ...
我的問題是,pathTransition.stop()停止動畫,但onFinished事件不會觸發。是否有任何解決方案在pathTransition停止後觸發事件?
我希望我的問題是可以理解的。
謝謝
,可以幫助我。謝謝你=) – jakob