什么时候HTML5 Swiffy动画完成的JavaScript侦听器?

时间:2013-04-29 19:24:09

标签: javascript javascript-events flash listener google-swiffy

有没有办法向Swiffy添加JavaScript侦听器,以便检测动画何时完成? (在SWF转换为Swiffy之前不编辑FLA)

在AS3中,我使用了加载SWF。 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 个答案:

答案 0 :(得分:1)

试试这个:

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

只需将alert替换为js中的任何内容。