2

Is there a way to add a JavaScript listener to Swiffy, in order to detect when animation is complete? (without editing the FLA before SWF conversion to Swiffy)

In AS3 I used a loading SWF. Is there something like this in JS:

private function loadAnimationCompleteListener():void { 
    //add listener for when animation is complete
    animation.addEventListener(Event.ENTER_FRAME, isAnimationComplete);
}

//tell me when the intro animation is complete
private function isAnimationComplete (e:Event):void {
      if (e.target.currentFrame == e.target.totalFrames) {
          //do something here
          //remove listener
          animation.removeEventListener(Event.ENTER_FRAME, isAnimationComplete);
      }
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

1

Try this:

private function loadAnimationCompleteListener():void { 
    //add listener for when animation is complete
    animation.addEventListener(Event.ENTER_FRAME, isAnimationComplete);
}

//tell me when the intro animation is complete
private function isAnimationComplete (e:Event):void {
    if (e.target.currentFrame == e.target.totalFrames) {
        //do something here
        navigateToURL(new URLRequest("alert('animation complete.')"), "_self");
        //remove listener
        animation.removeEventListener(Event.ENTER_FRAME, isAnimationComplete);
    }
}

Just replace the alert with whatever you want from the js.

blvz
  • 1,335
  • 13
  • 15