I have an XMLListCollection object that contains items with an ID property. I want to find one particular item by id and then get it's index in the collection. This is done to be able to tell the comboBox (whose dataProvider is the XMLListCollection) the index of the item to display.
Asked
Active
Viewed 2,156 times
1 Answers
2
See if this works: (replace 'item' with the appropriate tag name).
comboBox.selectedItem = XML(xmlListCol.source.item.(@id == requiredIndex));
If not, use this:
var list:XMLList = xmlListCol.source;
var index:Number = -1;
for(i = 0; i < list.length(); i++)
if(XML(list[i]).@id == requiredID)
{
index = i;
break;
}
if(index != -1)
comboBox.selectedIndex = index;
else
//deal with it

Amarghosh
- 58,710
- 11
- 92
- 121
-
The top didnt work, but the buttom worked a little better for me though I had to tweek it. Thanks! – Babyangle86 Mar 13 '10 at 09:51