package com.jwopitz.utils { // import mx.collections.ArrayCollection; // public class ArrayCollectionUtil { // //properties //-----------------------------------------------------------// // //constructor //-----------------------------------------------------------// function ArrayCollectionUtil (){ // } // //methods //-----------------------------------------------------------// public static function getPossibleMatches (searchIn:ArrayCollection, searchBy:ArrayCollection, propertyReference:String = null, ignoreDuplicates:Boolean = true):Array { /* searchIn - the collection to look for possible matches searchBy - the collection to compare against for possible matches referenceProperty - item property to use for comparison ignoreDuplicates - reserved for future functionality */ var temp_array:Array = new Array (); var i:uint = 0; var l:uint = searchBy.length; for (i; i < l; i++){ var j:uint = 0; var m:uint = searchIn.length; for (j; j < m; j++){ //need to address simple arrays of labels used for dataProviders if (typeof searchIn.getItemAt(j) != 'object') { //trace ('not object search'); if (searchIn.getItemAt(j) == searchBy.getItemAt(i)){ //we have a match //trace ('match'); temp_array.push (searchIn.getItemAt(j)); break; } } else { //trace ('object search'); if (searchIn.getItemAt(j)[propertyReference] == searchBy.getItemAt(i)[propertyReference]){ //we have a match //trace ('match'); temp_array.push (searchIn.getItemAt(j)); break; } } } } return temp_array; } // public static function findItem (searchIn:ArrayCollection, searchFor:*, propertyReference:String = null):Object { var foundObj:Object; var i:int = 0; var l:int = searchIn.length; for (i; i < l; i++){ // } return foundObj; } // //getters & setters //-----------------------------------------------------------// // } }