2012-08-29 68 views
1

我有以下代碼來生成新的爆炸影片剪輯。不幸的是,GameEvent.EXPLOSION_FINISHED事件從未被觸發。是否有每個幀的特殊事件監聽器?AS3 - 特定幀eventlistener?

var exp:Explosion = new Explosion(); 
exp.addFrameScript(exp.totalFrames - 1, function():void {exp.stop();dispatchEvent(new GameEvent(GameEvent.EXPLOSION_FINISHED));}); 
exp.addEventListener(GameEvent.EXPLOSION_FINISHED, tidyUp, false, 0, true); 

回答

1

我覺得你的問題是,你不派遣EXP對象上的事件,但對象的代碼塊是在試試這個:

exp.addFrameScript(exp.totalFrames - 1, function():void {exp.stop();exp.dispatchEvent(new GameEvent(GameEvent.EXPLOSION_FINISHED));}); 
+0

就是這樣。非常感謝! – Jan

0
stage.addEventListener(GameEvent.EXPLOSION_FINISHED,tidyUp); 
... 
function tidyUp(e:Event):void { 
    var s:Object=e.target; 
    if (s is Explosion) { 
     var expl:Explosion=s as Explosion; 
     // process your "expl" Explosion object here 
    } 
} 

應該做的。