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;
}

Recent Comments