Home > Flex 3.0 > Comparing Two Arraycollection

Comparing Two Arraycollection

// Both ArrayCollection need to have an same object

private function modifyItem( item:Object, arrc:ArrayCollection ):int {
var returnValue:int = -1;
var sort:Sort = new Sort();
sort.fields = [ new SortField( 'Name' ) ];
arrc.sort = sort;
arrc.refresh();
var cursor:IViewCursor = arrc.createCursor();
var found:Boolean = cursor.findAny( item );
if( found ) {
returnValue = arrc.getItemIndex( cursor.current );
}
return returnValue;
}

private function modifyItems( oldList:ArrayCollection, newList:ArrayCollection ):ArrayCollection {
var finalArr:ArrayCollection = new ArrayCollection()
for ( var i:int = 0; i < oldList.length; i++ ) {
var isItem:int =  modifyItem(  oldList.getItemAt( i ), newList  );
if( isItem == -1 ) {
finalArr.addItem( oldList.getItemAt( i ));
}
}
return finalArr;
}

About these ads
  1. No comments yet.
  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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: