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

Can't use dynamic values or binding for "the part after the =>'" in animations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • fx1.2
    • None
    • javafx
    • None

      Can't use dynamic values or binding for "the part after the =>'" in animations. According to Chris Oliver, this is a Timeline implementation bug. In the example below the animation will always start at 10 instead of 50 at the 2nd start:

      package e;

      import javafx.application.*;
      import javafx.scene.paint.*;
      import javafx.scene.geometry.*;
      import javafx.input.*;
      import javafx.scene.*;
      import javafx.scene.effect.*;
      import javafx.scene.image.*;
      import javafx.animation.*;
      import javafx.scene.text.*;
      import javafx.ext.swing.*;
      import java.lang.*;

      var dynX=10;
      var x=10 on replace { System.out.println(x); };

      var anim1 = Timeline {
           keyFrames : [
               KeyFrame {
                   time: 0s
                   values: [
      x => dynX
      // x => bind dynX //won't work
           ]
               },
               KeyFrame{
                   time: 4s
                   values: [
      x => dynX*2 tween Interpolator.LINEAR
      // x => bind dynX*2 tween Interpolator.LINEAR // won't work
      ]
               }
           ]
      }

      System.out.println("start1: "+x);
      anim1.start();
      System.out.println("end1: "+x);

      Thread.sleep(5000);
      dynX=50;

      System.out.println("start2: "+x);
      anim1.start();
      System.out.println("end2: "+x);



      ///////////////

      Will give the following output:
      10
      start1: 10
      end1: 10
      start2: 10
      end2: 10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20

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

              Created:
              Updated:
              Resolved:
              Imported: