Posted By

Activetuts on 01/13/11


Tagged


Versions (?)

Who likes this?

17 people have marked this snippet as a favorite

shuchii
chus
PLyczkowski
gandreini
elbjoern
toxin20
leadingmannigel
ichnoweb
kure69
AndrewPotter
im3der
souellette
elderhsouza
liakwee
frcomarin
timr
flashdeveloper


Remove All Children From a DisplayObjectContainer


 / Published in: ActionScript 3
 

URL: http://enva.to/e4ig6z

DisplayObjectContainer, a parent class of the more common container classes such as MovieClip and Sprite, does not have a built in method to immediately remove all children. To remove all children we simply use a while loop to remove the child which occupies index 0 in the stack until no children remain.

  1. while (displayObjectContainer.numChildren) {
  2. displayObjectContainer.removeChildAt(0);
  3. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: sidneydekoning on March 21, 2013

This can also be done by calling DisplayObjectContainer.removeChildren(). Needs AIR3.0 of FP11 and above.

See also http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#removeChildren%28%29

You need to login to post a comment.