I have seen numerous examples on how to remove duplicates in ArrayCollection but I can't seem to transpose this to XMLList. In most ArrayCollection examples, the example compares the key of the array with hasOwnProperty method and return a bool. That's fine, but what would I compare to when using an XMLList? Let's say I have:
<fx:XML id="testXML" xmlns="">
<universe>
<category cname="cat 1">
<item iname = "All"/>
<item iname = "item 1"/>
<item iname = "item 2"/>
</category>
<category cname="cat 2">
<item iname = "All"/>
<item iname = "item 3"/>
<item iname = "item 4"/>
</category>
</universe>
</fx:XML>
[actionscript]
var myList:XMLList = testXML..@iname;
will give two occurences of the item "ALL". I know I might have to convert the XMLList to an XMLListCollection to use the filterFunction (how would I go about doing that - or should I just define myList as an XMLListCollection right from the start). then on to the filterFunction:
private function remove Duplicate (item:Object): Boolean
{
here I don't know how to compare the item to tell me if the object already exist
or not. I guess I need to compare the item to a copy of the list and see if the
item has already been seen in the copy of the list. Or is there a clean way to
do this?
}
then all this is passed to a dropDownList:
<s:DropDownList id="myDDL" dataProvider="{myList}" />