zoukankan      html  css  js  c++  java
  • 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;
                }
            }
  • 相关阅读:
    java泛型介绍
    JavaWeb---总结(十九)Session机制
    ServiceWorker入门介绍一
    Ehcache入门介绍一
    Hadoop入门介绍一
    给安卓端调用的短信发送接口demo
    Java开发需要注意的流程
    一些题
    省选模拟3
    省选模拟2
  • 原文地址:https://www.cnblogs.com/as3lib/p/3751513.html
Copyright © 2011-2022 走看看