addFrameScript用法
如何判断一个mc播放完毕之后remove掉他呢,
目前我发现的两种做法,一种是:
var boomMc:MovieClip = LoadResource.getMC("boom",LoadResource.resourceDm); boomMc.id = x+":"+y; gameManager.gameWord.uiLayer.addChild(boomMc); var nxy:Point = Node.getPostionByXY(x,y); var p:Point = this.localToGlobal(nxy); boomMc.x = p.x; boomMc.y = p.y; boomMc.addEventListener(Event.ENTER_FRAME,_enterFrame); } private function _enterFrame(evt:Event):void { var boom:MovieClip = evt.target as MovieClip; if(boom.currentFrame == boom.totalFrames) { boomsPlayFinishedNo ++; boom.parent && boom.parent.removeChild(boom); boom.removeEventListener(Event.ENTER_FRAME,_enterFrame); } }
另一种高大上的方法是:
/** * NodeView 点击函数 */ public function nodeClickHandler(node:Node):void { if(node.type == Node.TYPE_BOMBSHELL) { BattleEffectUtil.vibrationScreen(gameManager.gameWord); var boomAll:MovieClip = LoadResource.getMC("boomAll",LoadResource.resourceDm); function _remove():void { boomAll.parent && boomAll.parent.removeChild(boomAll); } boomAll.addFrameScript(boomAll.totalFrames-1,_remove); gameManager.gameWord.uiLayer.addChild(boomAll); var nxy:Point = Node.getPostionByXY(node.x,node.y); var p:Point = gameManager.uiManager.gridView.localToGlobal(nxy); boomAll.x = p.x; boomAll.y = p.y; } }