Removing Everything from a Display Container

I ran into this problem and couldn’t figure out what was going on because I fail miserably:

// doesn't work because as this code executes numChildren is decreasing;
// it ends up not removing everything
for(var i:Number=0; i < numChildren; i++){
  removeChildAt(i);
}

The solution:

while( numChildren > 0 ){
  removeChildAt(0);
}

This expression is useful for deleting things from the bottom of the displayList up.