Avg. Rating 1.7

Problem

Unlike copying two simple objects, Copying the contents of two arraycollections can be a little tricky to newbie developers.

Solution

This method takes in two ArrayCollections and returns a single ArrayCollection which is a sum of the first two.

Detailed explanation

Ex -

ArrayCollection SRC 1 = A, B, C, D
ArrayCollection SRC 2 = 1, 2, 3, 4

ArrayCollection SUM = A, B, C, D, 1, 2, 3, 4

I hope this makes it clear enough :) . If there are more doubts, try it out ;) .

private function copyArrayCollection(src1:ArrayCollection, src2:ArrayCollection):ArrayCollection{
var dest:ArrayCollection = new ArrayCollection();
if(src1 != null && src1.length > 0){
for(var i:int = 0; i<src1.length; i++){
src2.addItem(src1.getItemAt(i));
}
}
dest = src2;
return dest;
}
Report abuse

Related recipes