Depth Management in AS3 = Z Order

Posted: September 30th, 2009 | Author: Liza | Filed under: As3, Flash, Uncategorized | Tags: , , , | No Comments »

I had a bit of trouble trying to figure out how to move the depth of an object on the stage in AS3 today. Its actually called Z-order in AS3, not Depth. Instead of just using the AddChild function, which put the Movie Clip on the top of the display list, I used AddChildAt, which set the depth of the Movieclip while it was adding it.

So instead of adding the child this way:

global.base.bgSprite.addChild(whiteTriangle);

where the movieclip was just dumped on top of everything

I used this

global.base.bgSprite.addChildAt(whiteTriangle, 1);

The 1 moved the depth of the movieclip to the base.

p.s. this was an external ActionScript file.