Posted By

StevenW721 on 11/10/10


Tagged

actionscript remove movieclip container removeChildAt


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

tspitzr
tombarc


Empty a container movieclip of all its children using AS3


 / Published in: ActionScript 3
 

Where "_description" is the movieclip instance, the following will remove all children from it. This for loop can also be used to do other things to all the children like adding listeners.

  1. // Empty out the container movieclip
  2. if ( _description.numChildren > 0 )
  3. { for (var i:uint = 0; i < _description.numChildren; i++)
  4. { _description.removeChildAt(i); }
  5. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: rkalexander1 on December 11, 2010

how would i call a function once the loop is completed and all the children have been removed?

Posted By: tattoogeek on January 17, 2011

I prefer

while ( _description.numChildren > 0 ) description.removeChildAt(0)

no if statement required and it can go on one line as well.

You need to login to post a comment.