Merge / Combine two ArrayCollections

// ArrayCollection 1
var arrC1:ArrayCollection;
// ArrayCollection 2
var arrC2:ArrayCollection; 
var array1:Array = arrC1.source
var array2:Array = arrC2.source
public function arrayContainsValue(arr:Array, value:Object):Boolean
{
       return (arr.indexOf(value) != -1);
}  
public function createUniqueCopy(a:Array):Array{
       var newArray:Array = new Array();        
       var len:Number = a.length;
       var item:Object;        
       for (var i:uint = 0; i < len; ++i)
       {
               item = a[i];                
               if(arrayContainsValue(newArray, item))
               {
                       continue;
               }
               newArray.push(item);
       }
       return newArray;
}  
var combinedArr:Array = createUniqueCopy(array1.concat(array2) );
var resultArrC:ArrayCollection =new ArrayCollection( combinedArr );
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: