• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Animation.currentRateProperty Becomes Negative

 
Gregory Larson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented this example from Intro To Java Programming - Liang. The animation is reversing direction on me, but it should not be doing that. It has a button to pause the animation, and a label to display the current rate. Here's what I do that causes the problem:

1. Press the Pause button

2. Change the rate (using the arrow keys)

3. Press the Pause button (this resumes the animation)

4. Change the rate again - this causes the direction to reverse!

The rate is always set to a positive value. When the animation reverses, I notice that currentRateProperty has become negative. It is a read-only property, and nothing I do can make it positive again.

 
John Damien Smith
Ranch Hand
Posts: 299
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if changing the rate of a running animation is a supported feature or not. The animation documentation doesn't say that you can't do it, but there are similar restrictions on Timelines that you can't change keyframes of executing timelines, so maybe changing the rate of a running animation is something that you shouldn't do either. I suggest you file a bug report in the JavaFX issue tracker to have somebody investigate.

Your sample seems to work if you stop the animation before you make the rate change and then start it again (from where its previous progress position) after the rate change has been made:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic