AS3: remove all childs

A code snippet I tend to use quite often. And one that I tend to forget how I wrote the last time i used it.

while (this.numChildren > 0)
{
    removeChild(this.getChildAt(0));
}

// Remove children as part of an event handler
private function eventHandler(e:Event):void
{
    e.target.parent.removeChild(e.target);
}

// When using Flex
someObject.removeAllChildren();

Tags: , , , ,

No comments yet.

Leave a Reply