Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8109577

Timeline regression: Changing a key value doesn't affect the behavior of a running Timeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • fx1.3
    • javafx

      In the following program (and attached), even though a key value in a KeyFrame is altered, the behavior of the Timeline is not affected. This used to work, and I first noticed the issue in the SDK 1.3 b27 partner release. Thanks! Jim Weaver.

      /*
       * MetronomeDynVals.fx - A simple example of animation using a Timeline
       * with dynamic KeyFrame time and values.
       *
       * Developed 2009 by James L. Weaver jim.weaver [at] javafxpert.com
       * as a JavaFX Script SDK 1.2 example
       */
      package projavafx.metronome.ui;

      import javafx.animation.KeyFrame;
      import javafx.animation.Interpolator;
      import javafx.animation.Timeline;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Slider;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.shape.Line;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.layout.HBox;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;

      var durMs:Number = 1000;
      var xVal:Number = 100;
      var yVal:Number = 50;
      var endXVal:Number = 300 on replace {
        println("endXVal is now:{endXVal}");
      };
      var endYVal:Number = 50 on replace {
        println("endYVal is now:{endYVal}");
      };
      var anim = Timeline {
        keyFrames: [
          KeyFrame {
            time: 0ms
            values: [
              xVal => 100,
              yVal => 50
            ]
          },
          KeyFrame {
            time: bind 2000ms - (durMs * 1ms)
            values: [
              xVal => endXVal tween Interpolator.LINEAR,
              yVal => endYVal tween Interpolator.LINEAR
            ]
          },
          KeyFrame {
            time: bind (2000ms - (durMs * 1ms))*2
            values: [
              xVal => 100,
              yVal => 50
            ]
          }
        ]
        repeatCount: Timeline.INDEFINITE
      };

      Stage {
        title: "Metronome Dynamic Values"
        visible: true
        scene: Scene {
          width: 400
          height: 500
          content: [
            Rectangle {
              width: 400
              height: 500
              fill: Color.TRANSPARENT
              onMousePressed: function(me:MouseEvent):Void {
                endXVal = me.x;
                endYVal = me.y;
              }
            },
            Line {
              startX: bind xVal
              startY: bind yVal
              endX: 200
              endY: 400
              strokeWidth: 4
              stroke: Color.BLUE
            },
            HBox {
              layoutX: 60
              layoutY: 420
              spacing: 10
              blocksMouse: true
              content: [
                Button {
                  text: "Start"
                  disable: bind anim.running
                  action: function():Void {
                    anim.playFromStart();
                  }
                },
                Button {
                  text: "Stop"
                  disable: bind not anim.running
                  action: function():Void {
                    anim.stop();
                  }
                },
                Slider {
                  min: 100
                  max: 2000
                  width: 500
                  value: bind durMs with inverse
                },
              ]
            }
          ]
        }
      }

            bchristi Brent Christian
            jweaver Jim Weaver (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: