/ 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.
Expand |
Embed | Plain Text
// Empty out the container movieclip if ( _description.numChildren > 0 ) { for (var i:uint = 0; i < _description.numChildren; i++) { _description.removeChildAt(i); } }
Comments
Subscribe to comments
You need to login to post a comment.

how would i call a function once the loop is completed and all the children have been removed?
I prefer
while ( _description.numChildren > 0 ) description.removeChildAt(0)
no if statement required and it can go on one line as well.