Posted By

russdogg on 06/18/11


Tagged

as3 removechildren


Versions (?)

Remove all children


 / Published in: ActionScript 3
 

  1. function removeChildrenFrom(mc:MovieClip):void
  2. {
  3. if(mc.numChildren!=0)
  4. {
  5. var i:int = mc.numChildren;
  6. while(i --)
  7. {
  8. mc.removeChildAt(i);
  9. }
  10. }
  11. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: JorRy on June 19, 2011

How about

[code] function removeChildremFrom(mc:MovieClip):void { while(mc.numChildre != 0) mc.removeChildAt(0); } [/code]

Posted By: janitha on June 22, 2011

@JorRy Much better

Posted By: russdogg on August 26, 2011

@JorRy Nice, cleaner to take out that extra if statement :)

You need to login to post a comment.