802/090
AS3-DisplayList关于容器显示列表
关于容器内的子容器列表的操作,主要是读取和删除。
Maybe you want to get the list of a container or want to delete all child of a container?
Then how to do this?Here is an idea to get the list of a container:
function getDisplayList(_mcContainer:DisplayObjectContainer):void{
var child:DisplayObject;
for(var i:uint=0; i < _mccontainer.numChildren;i++){
child=_mcContainer.getChildAt(i);
if(_mcContainer.getChildAt(i) is DisplayObjectContainer){
//Recursive function calls to get full DisplayObject list
getDisplayList(DisplayObjectContainer(child));
}
}
}
Then how to delete all children of a container?
Core codes here:
function delDisplayList(_mcContainer:DisplayObjectContainer):void{
do{
_mcContainer.removeChildAt(0);
if(_mcContainer.getChildAt(0) is DisplayObjectContainer){
//Recursive function calls to delete all children of the container
delDisplayList(DisplayObjectContainer(_mcContainer.getChildAt(0)));
}
}
while(_mcContainer.numChildren > 0);
}
Is this all?No no no,there are much more useable idea to do this.
If you have any idea about DisplayObject,DisplayObjectContainer,or as3?
You can leave your idea here,thx.