Vote count: 0
I would like to modify a Timeline while it is running, for example in response to a mouse-click I want to change the target value of the animation. I have tried several methods to do this including (in a mouse clicked handler) :
- Pausing the animation by calling
pause()on theTimeline, clearing theKeyFramesObservableList, adding a newKeyFrameand callingplay()on theTimeline. - Creating a new KeyFrame with a Cue-name, adding the new frame to the Observable list and calling
jumpTo(cueName)on theTimeline.
Some example code is:
String cueName = String.valueOf(System.currentTimeMillis());
KeyValue kv = new KeyValue(myObject.rotateProperty(), -90 + 180.0 * Math.random(), new CustomInterpolator());
KeyFrame kf = new KeyFrame(Duration.seconds(10), cueName, kv);
startupTimeline.getKeyFrames().add(kf);
startupTimeline.jumpTo(cueName);
startupTimeline.play();
Neither of these appear to work, the animation just stops.
Should I be able to modify the KeyFrame list of an existing Timeline or do I need to create a new Timeline if I want to change an animation while it is executing?
asked 1 min ago
Add A New KeyFrame to Timeline While an Animation is Executing
Aucun commentaire:
Enregistrer un commentaire