0 Replies Latest reply on Dec 20, 2007 5:30 AM by supertimvanderh

    problem catching events from my ComboBoxItemRenderer

    supertimvanderh
      Hi all,

      I have a problem catching a custom event dispatched by my custom ComboBoxItemRenderer. In the renderer I dispatch an event as follows:
      dispatchEvent(new Event("smallTest",true,true));

      As this is a bubbling event i expected to be able to catch it in one of the parent containers. However, the opposite is true. Then, lowering my goals i tried to catch the MouseEvent.CLICK event raised by the button in the ComboBoxItemRenderer. I failed in the same way...

      Somebody has a clue? Thanks in advance!
      (the following is an isolated description of my small problem ;-)

      The Mainapp
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute" xmlns:local="*">
      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;

      [Bindable]
      public var aDataProvider:ArrayCollection = new ArrayCollection(
      [ {label:"one", data:1},
      {label:"two", data:2},
      {label:"three", data:3} ]);

      private function init() : void {
      addEventListener("smallTest", doAlert);
      }

      private function doAlert(event : Event) : void {
      Alert.show("yo");
      }
      ]]>
      </mx:Script>

      <mx:ComboBox id="cb" itemRenderer="ComboBoxItemRenderer" dataProvider="{aDataProvider}" width="200"/>
      </mx:Application>

      The Renderer
      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
      <mx:Script>
      <![CDATA[
      import mx.core.Application;
      private function doClick() : void {
      dispatchEvent(new Event("smallTest",true,true));
      }
      ]]>
      </mx:Script>

      <mx:Label color="red" text="{data.label}"/>
      <mx:Spacer width="100%"/>
      <mx:Button label="*" width="40" click="doClick()"/>
      </mx:HBox>