Flex跟AS3的深度管理及排序
Flex和AS3的深度管理及排序
Flex和AS3的深度管理及排序
AS3中,我们通过下面的方法来操作和管理物体的显示深度排序。
numChildren : int
//返回此对象的子项数目。
getChildAt(index:int):DisplayObject
//返回位于指定索引处的子显示对象实例。
getChildIndex(child:DisplayObject):int
//返回 DisplayObject 的 child 实例的索引位置。
setChildIndex(child:DisplayObject, index:int):void
//更改现有子项在显示对象容器中的位置。
swapChildren(child1:DisplayObject, child2:DisplayObject):void
//交换两个指定子对象的 Z 轴顺序(从前到后顺序)。
swapChildrenAt(index1:int, index2:int):void
//在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺 序)。
removeChildAt(index:int):DisplayObject
//从 DisplayObjectContainer 的子列表中指定 的 index 位置删除子 DisplayObject。
setChildIndex常用有以下几种:
置顶: 容器.setChildIndex(对象A,容 器.numChildren-1);
置底: 容器.setChildIndex(对象A,0);
插入对象B的前面: 容器.setChildIndex(对象A,容 器.getChildIndex(对象B));
插入对象B的后面: 容器.setChildIndex(对象A,容 器.getChildIndex(对象B)-1);
Flex和AS3的深度管理及排序
AS3中,我们通过下面的方法来操作和管理物体的显示深度排序。
numChildren : int
//返回此对象的子项数目。
getChildAt(index:int):DisplayObject
//返回位于指定索引处的子显示对象实例。
getChildIndex(child:DisplayObject):int
//返回 DisplayObject 的 child 实例的索引位置。
setChildIndex(child:DisplayObject, index:int):void
//更改现有子项在显示对象容器中的位置。
swapChildren(child1:DisplayObject, child2:DisplayObject):void
//交换两个指定子对象的 Z 轴顺序(从前到后顺序)。
swapChildrenAt(index1:int, index2:int):void
//在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺 序)。
removeChildAt(index:int):DisplayObject
//从 DisplayObjectContainer 的子列表中指定 的 index 位置删除子 DisplayObject。
setChildIndex常用有以下几种:
置顶: 容器.setChildIndex(对象A,容 器.numChildren-1);
置底: 容器.setChildIndex(对象A,0);
插入对象B的前面: 容器.setChildIndex(对象A,容 器.getChildIndex(对象B));
插入对象B的后面: 容器.setChildIndex(对象A,容 器.getChildIndex(对象B)-1);