我正在尝试从容器中删除多个 mc。为什么容器也被移除?
///breadcrumbs
var randomMc:Number = Math.floor(Math.random()*myArray.length);
var mc:MovieClip = new myArray[randomMc];
MapHolder.addChild(mc);
mc.x = MapHolder.Star.x;
mc.y = MapHolder.Star.y;
/// remove breadcrumbs ///
function removeAllChildren(MapHolder:DisplayObjectContainer)
{
while(MapHolder.numChildren > 0)
{
MapHolder.removeChild(MapHolder.getChildAt(0));
}
}
//////
我想我解决了我的问题......因为孩子在容器里......它需要索引 1 吗?
function removeAllChildren(DisplayObjectContainer):void
{
while(MapHolder.numChildren > 1) {
MapHolder.removeChildAt(1);
}
}