Posted By

snick on 06/18/09


delete as3 movieclips

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Delete all MovieClips inside a MovieClip

 / Published in: ActionScript 3

Consider that we have a container (MovieClip) named \"cont\"\r\nand we want to erase all the movieclip inside it.

  1. while (cont.numChildren > 0){ cont.removeChildAt(0); }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: sweetbabyyoung on June 23, 2009

You can also do something like:

while (cont.numChildren > 0){ cont.removeChildAt(0); }

Posted By: moselicious on July 4, 2009

You're right. That's much cleaner for removing all children. On the other hand you can't add any exceptions/filters like this:

for(var i:int = cont.numChildren-1; i>=0; i--) if (cont.getChildAt(i).x > 400){ this.removeChildAt(i); } }

Perhaps i should have set a better title and example code. Thanks for your advice!

Posted By: moselicious on July 4, 2009

sorry, thought it was my own post, but i just "faved" it :-)

You need to login to post a comment.