AS2 - Remove all movieclip instances

Hello! Good day to you!!!

Could you help me with something please? Is there a code to remove all instances of a particular movieclip on stage? The code

removeMovieClip(target);

removes just one particular instance. That wont do for me at all! I need to remove all the instances. How do I do that?

Thank you!!! Have a good day!

if all your clips are on the same time timeline - lets say they’re in a clip named “holder”, and all your clips are named with the prefix “foo_”:

one way::


for(var i in holder) {
    if(typeof(holder*)=="movieclip" && holder*._name.substr(0,4)=="foo_") {
           // if you're clips are not dynamically attached, then de-comment this line:
           //holder*.swapDepths(10000);
           holder*.removeMovieClip();
    }
}

I didn’t really understand that code… Hmmm, all my instances aren’t placed in another clip… they are all on the time line… if they were in another clip, maybe i would just unload that clip all together…

I can’t put them all in one other clip because each instance has a code to drag its parent, so i guess that would mean that all of them would get dragged together right?

Thanks for your help! You said that that was one way… Is there another way? Greatly appreciate it!

name your moviclips as mc1 mc2 mc3 etc: either by code or manually.
then for removing all… use

for(var i=0;i<noOfclips;i++)
{
var clip=_root[“mc”+i];
clip.removeMovieClip();
}

[quote=Noahdecoco;2330962]I didn’t really understand that code… Hmmm, all my instances aren’t placed in another clip… they are all on the time line… if they were in another clip, maybe i would just unload that clip all together…

I can’t put them all in one other clip because each instance has a code to drag its parent, so i guess that would mean that all of them would get dragged together right?

Thanks for your help! You said that that was one way… Is there another way? Greatly appreciate it![/quote]

you could also just plop them all into a single movieclip

instead of all in the _root timeline plop them into a movie clip that you could then kill whenever you wanted

Hey, thanks man… it worked fine! Right now I’m hardcoding the number of movieclips to 1000, but in the future, I’ll make a counter to count each movie clip as it gets loaded so that at the end I know exactly how many there are…

Nice code! Works fine!