1

I'm using the combobox component and I want to manually dispatch the "change" event. How is this done?

// Dispatches when user changes selection
comboType.addEventListener("change",cbListenerDialogue);

// Does not manually dispatch
comboType.dispatchEvent("change"); 
comboType.dispatchEvent(new Event("change"));
Abdulla
  • 1,117
  • 4
  • 21
  • 44

2 Answers2

5

The string value you use for the dispatch has to match what's already defined in Flash.

This should to the trick.

comboType.dispatchEvent(new Event(Event.CHANGE, true));

Also: AS3 Textbox Change Event Not Firing

Community
  • 1
  • 1
1

Just to be clear,

comboType.dispatchEvent(new Event(Event.CHANGE, true));

works because bubbling is set to "true".

For example,

comboType.addEventListener("change",cbListenerDialogue);
comboType.dispatchEvent(new Event("change", true));

would work too. The important thing is that non mouse events won't propagate (bubble) unless set to true as Event.CHANGE and "change" are the same thing.

davedev
  • 105
  • 6