2 Replies Latest reply on Feb 27, 2008 11:48 AM by ericbelair

    How to clone an Array Collection without binding the new one to the old one?

    ericbelair Level 1
      I am creating an Array Collection from a WebService Result. At a later part in the code, I am creating a copy of that Array Collection, in order to apply a filter. However, when I make a change to the new Array Collection, it updates the original Array Collection.

      How can I avoid this? I want the new Array Collection to be it's own entity that I can update on the fly without affecting the original Collection.

      Since this forum does not have an "Attach Code" option, here is a small sample of my code:

      private var aColl1:ArrayCollection;
      private var aColl2:ArrayCollection;


      // WebService Result Handler

      aColl1 = ws.lastResult as ArrayCollection;


      // Another function in the same Application

      aColl2 = new ArrayCollection(aColl1.toArray());

      aColl2.filterFunction = myFilter;



      // A third function in the same Application

      for each (var object:Object in aColl2)
      object[property] = "newValue"; // This updates the same Object in the original Array Collection