I populate an ArrayCollection from the server and use it as a DataProvider to a DataGrid.
I want to only send what has changed (the delta) back to the server.
So, I save the original into another ArrayCollection with the idea of using it to compare with the original. Like this:
public var ArrayCollection1:ArrayCollection = new ArrayCollection(); public var ArrayCollection2:ArrayCollection = new ArrayCollection(); (ArrayCollection1 populated from the server) ArrayCollection2 = ArrayCollection1;
However, the second ArrayCollection's underlying Array has the same ObjectId as the first one. Therefore, when the data is changed in the DataGrid, it changes both ArrayCollections.
Is there a way to force the second ArrayCollection's underlying Array to be a separate object instead of a reference to ArrayCollection1's Array ?
I guess I'm not the only one not watching the Stupor Bowl right now.
I found this article too: http://jodieorourke.com/view.php?id=105&blog=news
The ObjectUtil syntax is very clean:
ac2 = new ArrayCollection( ObjectUtil.copy (ac1.source) as Array);