You can use selectedIndex to change a comboBox, but the selectedIndex is usualy independent from the data or the label properties of the Object. Apparently there is no way of doing a reverse look up to select the item, you have to searh through and find it yourself (if you know a better way, let me know!).
function reverseSetComboBox(target:String, targetComboBox:ComboBox, targetDataProvider:Array):void {
//loop over the items in the dataProvider
for (var i:uint = 0; i<targetComboBox.length; i++) {
//compare desired value to current item.data value
if (target==targetDataProvider[i].label) {
//set the seletedIndex of the combo box
targetComboBox.selectedIndex = i;
}
}
}
No comments:
Post a Comment