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);
      }
}

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.