This Utility gives you Distinct values from your source array collection. It iterates through the Source ArrayCollection and gets the item Object for each loop and checks to see if the property value of the item is present in the new Collection. If its not present then it add’s the item to the new Collection, else it ignore’s the item and iterates the next item in the list. This is done by getItemIndex property of the ArrayCollection.
public static function getDisticntArrayCollection(sourceCollection:ArrayCollection):ArrayCollection{ var distinctValuesCollection:ArrayCollection = new ArrayCollection(); for each(var item:* in sourceCollection){ var propertyValue:Object = item.VALUE; if(distinctValuesCollection.getItemIndex(propertyValue) == -1) distinctValuesCollection.addItem(item); } return distinctValuesCollection; }
thanks, it helped…