1 Reply Latest reply on Feb 1, 2007 8:45 AM by FlightGuy

    dispatchEvent not working

    theLoggerGuy Level 1
      Okay, I know I'm doing something stupid, but I can't see it. My event never happens, but the "dispatch" is called.

      First I declare and instantiate my event:
      private var rvgEvent: Event = new Event( "returnValueGathered" );

      Then at the appropriate time I add the event to the queue:
      this.addEventListener( "myEvent", updateDisplay );

      Then when the trigger part happens I trigger the event:
      dispatchEvent( rvgEvent );

      I suspect that I am cutting a corner somewhere on the addEventListener call as I am not creating a custom event listener because I don't know how. So if anyone can give me some help I'd appreciate it.
        • 1. Re: dispatchEvent not working
          FlightGuy Level 1
          First, don't bother creating the event in advance - it's intended for a one-time use. Just create it when you dispatch it:

          dispatchEvent(new Event("returnValueGathered"));

          Your event listener needs to be listening for an event of the same type:

          addEventListener("returnValueGathered", updateDisplay);

          Then you need the updateDisplay function you've just referenced:

          private function updateDisplay(event:Event):void{
          trace("hi");
          }

          Tim