0 Replies Latest reply on Dec 2, 2008 1:54 PM by blipstation

    Custom Event not bubbling up to grandparent

    blipstation
      I have the following hierarchy of custom components written in AS:

      AltDialogue extends UIComponent
      ----- AltChoice extends HBox
      ----------- ToggleButton extends Button and which dispatches the following event:

      package components.events
      {
      import flash.events.Event;

      public class ToggleEvent extends Event
      {
      public static const TOGGLE_EVENT:String="toggleEvent";
      public var open:Boolean;

      public function ToggleEvent(open:Boolean, bubbles:Boolean=true, cancelable:Boolean=false)
      {
      super(TOGGLE_EVENT, bubbles, cancelable);
      this.open=open;

      }

      public override function clone():Event{
      return new ToggleEvent(open, bubbles,cancelable);
      }



      I can get AltChoice (the parent) that has the ToggleButton instance called _dropdownBut to listen to the event via:

      _dropdownBut.addEventListener(ToggleEvent.TOGGLE_EVENT,toggleListener);

      private function toggleListener(e:ToggleEvent):void{
      trace(e.open);//works
      }

      But when I try to listen to the event from AltDialogue (the grandparent) that has the AltChoice instance _choice with this:

      _choice.addEventListener(ToggleEvent.TOGGLE_EVENT,toggleDropdown);

      private function toggleDropdown(e:ToggleEvent):void{
      if(e.open)
      trace("open dropdown");
      else
      trace("remove dropdown");
      }

      I get nothing traced out in debug mode and that's where I want to respond to the event. What am I missing?