Two Objects created with the same Address in Flex
Posted
by James
on Stack Overflow
See other posts from Stack Overflow
or by James
Published on 2010-05-20T10:27:18Z
Indexed on
2010/05/20
10:30 UTC
Read the original article
Hit count: 223
Hi,
I have an issue in flex which is causing a bit of a headache!
I am adding objects to an ArrayCollection but in doing so, another ArrayCollection is also picking up these changes even though there is no binding occurring.
I can see from the debug that the two ACs have the same address but for the life of me can't figure out why.
I have two Array Collections:
model.index.rows //The main array collection
model.index.holdRows //The array collection that imitates the above
This phantom data binding occurs only for the first iteration in the loop and for all others it will just write it the once.
The reason this is proving troublesome is that it creates duplicate entries in my datagrid.
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();
}
}
Has anyone else who has encountered something simillar propose a solution?
© Stack Overflow or respective owner