title: AS3 dispatchEvent not working
body: <p>I've searched other examples of dispatching events and none of them have helped me. </p>
  
  <p>Here is what I have so far. I know that the event listener is added successfully, but the event is never dispatched. </p>
  
  <p>In a .mxml file:</p>
  
  <pre><code>function foo():void {
  
      var eventClassObj:MyEventClass = new MyEventClass();
  
  
  }
  </code></pre>
  
  <p>In a separate .as file:</p>
  
  <pre><code>public class MyEventClass extends EventDispatcher 
  {
  
      public function MyEventClass(target:flash.events.IEventDispatcher = null) 
      {
  
                      //ADD EVENT LISTENER
          this.addEventListener("test", testFunc, true);
  
  
  
                      //DEBUGGING PRINT STATEMENTS
          var str:String;
          if (this.hasEventListener("test")) {
                  str = "EVENT LISTENER ADDED";
          } else {
                  str = "NO LISTENER";
          }
  
          ExternalInterface.call("console.log", str);
  
                      //DISPATCH EVENT
          this.dispatchEvent(new Event("test", true));
      }
  
  
      //THIS MUST EXECUTE WHEN EVENT DISPATCHED
      private function testFunc(e:Event):void {
          ExternalInterface.call("console.log", "dispatch event successful");
      }
  }
  </code></pre>
  
  <p>I am completely new to ActionScript3. Do you know why the event is never dispatched? My output in the console for running this would only be:</p>
  
  <pre><code>EVENT LISTENER ADDED
  </code></pre>
  
  <p>while my expected output is:</p>
  
  <pre><code>EVENT LISTENER ADDED
  dispatch event successful
  </code></pre>
  
  <p>I don't see why this wouldn't work. </p>