Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 使用DataGrid添加Child,但我不知道如何通过选择其他项来删除_Actionscript 3 - Fatal编程技术网

Actionscript 3 使用DataGrid添加Child,但我不知道如何通过选择其他项来删除

Actionscript 3 使用DataGrid添加Child,但我不知道如何通过选择其他项来删除,actionscript-3,Actionscript 3,请帮帮我 我在离线地图中工作,从XML中读取数据。我将数据放在DataGrid中,当我从DataGrid中选择项时,我在阶段中添加子项,并创建一个movieclip,因为数据一次可能不止一个子项,但当我从DataGrid中选择另一个项时,添加了新的子项,但没有删除旧的子项 这是我的代码: 只需将要添加的movieclip放入容器movieclip。 也许是这样的: familyGrid.addEventListener(Event.CHANGE, get_data2); var familyCo

请帮帮我

我在离线地图中工作,从XML中读取数据。我将数据放在DataGrid中,当我从DataGrid中选择项时,我在阶段中添加子项,并创建一个movieclip,因为数据一次可能不止一个子项,但当我从DataGrid中选择另一个项时,添加了新的子项,但没有删除旧的子项

这是我的代码:
只需将要添加的movieclip放入容器movieclip。 也许是这样的:

familyGrid.addEventListener(Event.CHANGE, get_data2);
var familyContainer = new MovieClip();
addChild(familyContainer);
在get_data2函数中,执行以下操作

function get_data2(event:Event):void {
    ...
    removePreviousChildren();
    familyContainer.addChild(markLoader);
    ...
}

function removePreviousChildren() {
    while(familyContainer.numChildren > 0) {
        familyContainer.removeChild(familyContainer.getChildAt(0))
    }
}
function get_data2(event:Event):void {
    ...
    removePreviousChildren();
    familyContainer.addChild(markLoader);
    ...
}

function removePreviousChildren() {
    while(familyContainer.numChildren > 0) {
        familyContainer.removeChild(familyContainer.getChildAt(0))
    }
}