0

I have been searching all around for a guide on event handling in flash builder 4.5. I have a dropdownlist that I'd like to activate preferably a action script function. similar to asp.net/js.

cheers!

Sam
  • 281
  • 2
  • 6
  • 15
  • Adobe TV has a great series that focus' on Flex SDK and Flash Builder 4.5 IDE more so than many tutorials out there. [Flex-In-A-Week](http://tv.adobe.com/show/flex-in-a-week). They go into a decent level of detail on Events. IMO the event system is Flex's saving grace. – smulholland2 Oct 11 '11 at 02:52

1 Answers1

0

right out of as3 docs with some comments...

import fl.controls.ComboBox;
import fl.controls.Label;

var myComboBox:ComboBox = new ComboBox();
myComboBox.prompt = "Please select an item...";
myComboBox.addItem({label:"Item 1"});
myComboBox.addItem({label:"Item 2"});
myComboBox.addItem({label:"Item 3"});
myComboBox.addItem({label:"Item 4"});
myComboBox.width = 150;
myComboBox.move(10, 10);
myComboBox.addEventListener(Event.CHANGE, changeHandler);  // <- ASSIGN EVENT LISTENER
addChild(myComboBox);

var myLabel:Label = new Label();
myLabel.autoSize = TextFieldAutoSize.LEFT;
myLabel.text = "selectedIndex:" + myComboBox.selectedIndex;
myLabel.move(myComboBox.x + myComboBox.width + 10, myComboBox.y);
addChild(myLabel);

function changeHandler(event:Event):void {   // <- ASSIGN FUNCTION
    myLabel.text = "selectedIndex:" + myComboBox.selectedIndex;
}

Also from the docs, these are the events...

change Dispatched when the user changes the selection in the ComboBox component or, if the ComboBox component is editable, each time the user enters a keystroke in the text field. ComboBox

close Dispatched when the drop-down list is dismissed for any reason. ComboBox

enter Dispatched if the editable property is set to true and the user presses the Enter key while typing in the editable text field. ComboBox

itemRollOut Defines the value of the type property of an itemRollOut event object. ComboBox

itemRollOver Defines the value of the type property of an itemRollOver event object. ComboBox

open Dispatched when the user clicks the drop-down button to display the drop-down list. ComboBox

scroll Dispatched when the user scrolls the drop-down list of the ComboBox component. ComboBox

Daniel
  • 34,125
  • 17
  • 102
  • 150