Tuesday, May 3, 2011

AS3 - Children adding reverse

Today I learned an extra feature of adding children into a DisplayObject in reverse.
Normally I would make two loops. First one is adding the children, the second is placing the children in reverse.
But... it can be done so much easier:

for(var i:int = 0; i < numChildren; i++)
{

container.addChildAt(child,0);

}

The second parameter sets the child on the first place.

For many known, not for me.. maybe not for you either....