4

In Adobe Edge Animate, how to get Symbol's current time ?

I use a mix of jQuery & Adobe Edge codes to program my page. I want to check if a symbol's time stays at first frame (if in Flash's concept).

$(window).scroll(function(e) 
{
   var the_stage = $.Edge.getComposition("EDGE-123456").getStage();
   var sym = the_stage.getSymbol(id);
   // how to get current time ?
});
Raptor
  • 53,206
  • 45
  • 230
  • 366

2 Answers2

6

Finally found a solution. To get the current time, use:

var pos = sym.getPosition()

pos is an integer . If the symbol hasn't played before, its value is -1, else it is the position in milliseconds.

Raptor
  • 53,206
  • 45
  • 230
  • 366
2

Your solution is ok, but need clarification.

If your animation is "inside" the div:

<div id="stage_animation_0" class="animation_0"></div>

I suggest to name class attribute with "animation_" + animation number and id attribute with "stage_" + class name.

GET

You can obtain actual timeline position in this way:

var getAnimationPos = function(animation) {     
  var stage = $.Edge.getComposition(animation).getStage();
  var sym = stage.getSymbol("stage_" + animation);
  return sym.getPosition();
}

In this way you can obtain your timeline position with:

var position = getAnimationPos("animation_0");

SET

Setting the actual timeline position is more "complicated".

If your animation is playing and you want to jump to a specific position:

var jumpPosition = 300; /* expressed in milliseconds */
$.Edge.getComposition(animation).getStage().play(jumpPosition);

If your animation is paused and you want to set position without play, you have to:

var jumpPosition = 300; /* expressed in milliseconds */
$.Edge.getComposition(animation).getStage().stop(jumpPosition);

In this way, when you'll call play(), animation will start from position 300.

Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146