How to make a MovieClip remove itself in AS3?

后端 未结 5 1470
不思量自难忘°
不思量自难忘° 2021-01-18 13:41

What is the equivalent to removeMovieClip() in AS3?

Apparently many have the same question:
StackOverflow:

  1. How to completely remove a
5条回答
  •  走了就别回头了
    2021-01-18 14:30

    Always ensure that those self removing movieclips can get garbage collected. This solution wiped away all my instances from a loaded swf's library symbol:

    var mc:MovieClip = new definition() as MovieClip;
    addChild(mc);
    
    mc.x = 1000 * Math.random();
    mc.y = 1000 * Math.random();
    
    mc.addFrameScript(mc.totalFrames - 1, function onLastFrame():void
    {
        mc.stop();
        mc.parent.removeChild(mc);
        mc = null;
    });
    

提交回复
热议问题