2013-04-29 53 views
2

有沒有一種方法可以將Swallow添加到JavaScript偵聽器中,以便檢測動畫何時完成? (在SWF轉換爲Swiffy之前無需編輯FLA)HTML5 Swiffy動畫完成時的JavaScript監聽器?

在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

試試這個:

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

只是無論你從JS想更換alert