2 Replies Latest reply on Feb 6, 2011 5:06 PM by WebTrauma

    Howto set ArrayCollection1 = ArrayCollection2 without making the underlying array the same object ?

    WebTrauma Level 1

      Hi,

       

      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 ?

       

      thanks!