Before any details, here is the snippet that should remove the MovieClip from stage:
clipToRemove.parent.removeChild(clipToRemove); //provided clipToRemove has no parent otherwise that path will also include //but you get the logic here anyway
In AS2, removeMovieClip(this) would do the job for removing any clip from stage, but AS3 has changed the things and have made them very logical. Logical only if you have spent some time practicing it, otherwise it just does not make sense.
In AS3, I have found the following technique the easiest to remove any MovieClip.
To dynamically place a MovieClip on stage in AS3, you need to use:
addChild(clipName); //And similarly, you can remove it by: removeChild(clipName); //hold the clip reference in this variable var selectedClip:MovieClip = new MovieClip(); function removeClip():void{ selectedClip.parent.removeChild(selectedClip); } //create a movieClip on stage var containerClip:MovieClip = new MovieClip(); //add it on stage addChild(containerClip); //store its reference selectedClip = containerClip; //simply call the function when you have to removeClip();
When there’s no parent of the MovieClip, or you don’t know the parent, you simply can’t use removeChild(clipName). It just won’t work. To remove the clip, you need its parent reference and here’s the easy bit, just call it clipName.parent.removeChild(clipName);
Easy, isn’t it?
Hope that helps.
Cheers!
i have a problem with removing movie clip, and i can solve it with your trick, tx very much this all what i need ^^