How to copy an ArrayCollection by value
March 21st, 2008
I came across the requirement to copy an ArrayCollection by value instead of by reference. Here is the solutions I used:
1 2 3 4 5 | private var myCollection:ArrayCollection = new ArrayCollection(); for (var k:Number = 0; k < myCurrentCollection.length; k++) { myCollection.addItem(mx.utils.ObjectUtil.copy(myCurrentCollection[k])); } |
Categories: Flex













Just saw this, it works and is simpler.
newAC = ObjectUtil.copy (oldAC) as ArrayCollection;
Call to a possibly undefined method copy.
you have to import mx.utils.ObjectUtil
Thanks a lott
I got the solution after almost 5 hours.. but worth