updating SplineDoubleKeyFrame properties from javascript

behaviour is pretty errant, sometimes I can get it working other times don't.

I can't find the logic why it breaks on me.

basically I have in screen 100 elements, all created dynamically, looping over them updating their storyboards props and trying to move them around.

 

in javascript it goes something like:

for(var n=0;n<100;n++) {

  var target      = wpf.findName(objectID);
  var storyboard    = target.findName(storyboardID);
  var currentValue   = target.findName(objectElementID[objectElementProperty]);
  var startKeyframe  = storyboard.findName(startKeyFrameID);
  var endKeyframe   = storyboard.findName(endKeyFrameID)
  startKeyframe.value = (currentValue).toString();
  endKeyframe.value  = (value).toString();

  // this doesnt work:
  var delay = Math.floor(Math.random()*10)+1;
  endKeyframe.keyTime = "0:0:0."+delay;

  // this works sometimes, sometimes not, depends on the keytime
  // It was bugging making the storyboard jump directly to the last value
  // storyboard.begin();
  // storyboard.stop();
  // the workaround sometimes is
  // storyboard.beginTime = "0:0:0.1";
  storyboard.begin();

}

 

 here's a working demo not really implementing the above, but you might take a look below the hood and see more clearly what I'm trying to do and how I'm trying to do it:

 http://marumushi.heteml.jp/temp/wpfe/test-003/

 

 



Answer this question

updating SplineDoubleKeyFrame properties from javascript

  • Jan Meeusen

    Unfortunately you can't set a KeyFrame's KeyTime on the fly. My guess is you're running into a roundoff issue on the Storyboards, which shouldn't repro without the BeginTime="1" workaround on the Storyboard.

    The way to accomplish what you want here is to create a new Storyboard each time with the appropriate KeyTimes.

    Thanks,
    Ed Maia
    WPF/E Program Manager


  • updating SplineDoubleKeyFrame properties from javascript