as3 中的Child Index层管理。它是完全自动的。当使用 addChild() 方法把 DisplayObject 加到一个 DisplayObjectContainer 的 display list ,它将自动获得从0开始的连续的 index 。于是你可以用 getChildAt(0) , getChildAt(1) … 分别获得第一个、第二个…加入显示列表(display list)的 DisplayObject ,这比 getChildByName() 方法更有效率。如果使用 addChildAt() 方法把一个 DisplayObject 加到一个已经存在的层,如上面提到的。

stage.addChildAt(stage_mc,0);
那么该层原有的以及所有该层之上的内容都自动上移一层(index + 1)。同样的,当使用 removeChild() 或 removeChildAt() 方法删除某一层的显示内容,所有该层之上的内容都会自动下移一层(index – 1)。注意 index 始终是连续的,如果现在的 numChildren 是4,也就是现有最大的 index 是3(0,1,2,3),你将不能 addChildAt(mc,5) 或者任何比5更高的层,编译器将报错:
“RangeError: Error #2006: The supplied index is out of bounds.”

addChildAt(child:DisplayObject, index:int)   可以设置深度
setChildIndex(child:DisplayObject, index:int)   调整深度 相当于swapDepth()
getChildIndex(child:DisplayObject)      得到深度,相当于getDepth()