Hi
I thought I had custom events nailed in Flex, but seemingly not. I am trying to loosely couple my application by dispatching events between classes instead of using horrid parent.parent.parent statements.
I have a ComboBox inside a custom HBox class... for simplicity I am doing the following
public function onComboBoxChange(event:MouseEvent):void {
trace("dispatching event");
dispatchEvent(new Event("hello"));
}
I have a custom List class that I would like to respond to the event...
public function CustomList() {
//...
this.addEventListener(FlexEvent.INITIALIZE, onInit);
}
private function onInit(event:FlexEvent):void {
this.addEventListener("hello", onHello);
}
private function onHello(event:Event):void {
trace("oh hello");
}
However the event listener is never called.
Both CustomList and CustomHBox have the same parent.
I was under the impression you could dispatchEvent from any object and all other active objects would be able to listen for it. Not that simple?
Thanks!