我在 flex 中有一个问题,这让我有点头疼!
我正在向 ArrayCollection 添加对象,但这样做时,即使没有发生绑定,另一个 ArrayCollection 也会获取这些更改。
我可以从调试中看到两个 AC 具有相同的地址,但我一生都无法弄清楚为什么。
我有两个数组集合:
model.index.rows //The main array collection
model.index.holdRows //The array collection that imitates the above
这种幻像数据绑定仅发生在循环中的第一次迭代中,而对于所有其他迭代,它只会写入一次。
这被证明很麻烦的原因是它在我的数据网格中创建了重复的条目。
public override function handleMessage(message:IMessage):void
{
super.handleMessage(message);
if (message is IndexResponse)
{
var response:IndexResponse = message as IndexResponse;
model.index.rows.removeAll();
model.index.indexIsEmpty = response.nullIndex;
if (model.index.indexIsEmpty !== true)
{
//Update the index model from the response. Note: each property of the row object will be shown in the UI as a column in the grid
response.index.forEach(function(entry:EntryData, i:int, a:Array):void
{
var row:Object = { fileID: entry.fileID, dadName: entry.dadName };
entry.tags.forEach(function(tag:Tag, i:int, a:Array):void
{
row[tag.name] = tag.value;
});
model.index.rows.addItem(row);
});
if(model.index.indexForNetworkView == true){
model.index.holdRows.source = model.index.holdRows.source.concat(model.index.rows.source);
model.index.indexCounter++;
model.index.indexForNetworkView = false;
controller.indexController.showNetwork(model.index.indexCounter);
}
model.index.rows.refresh();
controller.networkController.show();
}
}
有没有其他遇到类似情况的人提出解决方案?