/ Published in: ActionScript 3
URL: http://www.mechanicmatt.com
Expand |
Embed | Plain Text
Take a combobox with options, and an instance name of "myComboBox" private function findItemIndex (element:ComboBox, dataString:String):int { var index:int = 0; for (var i = 0; i < element.length; i++) { if (element.getItemAt(i).data.toString() == dataString) { index = i; break; } else { } } return index; } then to set the value and updated the selected item, just one line of code: myComboBox.selectedIndex = this.findItemIndex(myComboBox, "stringToMatch");
You need to login to post a comment.
