1 Reply Latest reply on Oct 14, 2009 11:20 AM by msakrejda

    dispatch an event

    malgi2

      Hi,

       

      I am trying to send a simple event. When I run the application in file1 and click the button in file2:

       

      - init() in file1 is called.

      - dispatch_event() in file2 is called.

      - but eventHandler() in file1 is NOT called.

       

      Am I missing anything?

       

      -------------------------------------------------------

      // file1.mxml

      <mx:Application ... creationComplete="init();">

       

      private function init():void
      {
         iad_screen = new iad();
         iad_screen.addEventListener("backtomain", backtoMain);

      }
         
      private function eventHandler(e:Event):void
      {
         Alert.show("Call Back backtoMain");
      }

      -------------------------------------------------------

      // file2.mxml

      <mx:Metadata>
          [Event(name="myevent")]
      </mx:Metadata>


      private function dispatch_event():void
      {
          this.dispatchEvent(new Event("myevent"));
      }

      <mx:Button label="Button" click="dispatch_event();"/>

      -------------------------------------------------------

      -