/ Published in: ActionScript 3

I copied this from my working example and tweaked some lines to make it generic. Thus there MAY be a typo which I haven't checked for, but probably not. This is what's needed to have something change upon selection of an item in a ComboBox.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// this code assumes the existance of a ComboBox (Components -> User Interface -> ComboBox) // on the stage with an instance name of "MY_DROPDOWN_INSTANCE_NAME" plus two items defined in its properties // named "Choice One" and "Choice Two" var MY_DROPDOWN_LISTENER:Object=new Object(); // a new listener MY_DROPDOWN_INSTANCE_NAME.addEventListener("change", MY_DROPDOWN_LISTENER); //add listener to combobox MY_DROPDOWN_LISTENER.change=function(){ //function called // do something based on the selected item's label switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().label) { case "Choice One": trace("one"); break; case "Choice Two": trace("two"); break; } // do something based on the selected item's value switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().data) { case "Choice One": trace("one"); break; case "Choice Two": trace("two"); break; } }
Comments
