4 Replies Latest reply on Feb 24, 2009 5:49 AM by Handycam

    Why am I not getting my event?

    Handycam Level 1
      In one of my components, I have this part of a function:
      if (itemsAnswered == itemsLst.length) {
      Alert.show("You got them all in "+Application.application.timeNow+" seconds.
      this.dispatchEvent(new Event("gameOver"));
      }

      I get the Alert, so that part works. However, my issue is the dispatched event...

      In the main application, its creation complete handler is:

      private function onCreationComplete():void {
      makeIntro();
      getData.send();
      this.addEventListener("gameOver", gameOverHandler);
      }

      However, it is not getting the event, since nothing in the gameOverHandler is working.

      What am I missing?
        • 1. Re: Why am I not getting my event?
          -Hob
          You need to specify that your event bubbles by specifying true as the 2nd parameter on the event's constructor. Like so:

          this.dispatchEvent(new Event("gameOver", true));
          • 2. Re: Why am I not getting my event?
            Level 7

            "Handycam" <webforumsuser@macromedia.com> wrote in message
            news:gnv2hu$5ga$1@forums.macromedia.com...
            > In one of my components, I have this part of a function:
            > if (itemsAnswered == itemsLst.length) {
            > Alert.show("You got them all in "+Application.application.timeNow+"
            > seconds.
            > this.dispatchEvent(new Event("gameOver"));
            > }
            >
            > I get the Alert, so that part works. However, my issue is the dispatched
            > event...
            >
            > In the main application, its creation complete handler is:
            >
            > private function onCreationComplete():void {
            > makeIntro();
            > getData.send();
            > this.addEventListener("gameOver", gameOverHandler);
            > }

            Try adding your event listener to the component that's dispatching the
            event.


            • 3. Re: Why am I not getting my event?
              Handycam Level 1
              Thanks, Hob, I needed to have it bubble.

              Amy, I couldn't do that since I needed the listener at the root of the app and the dispatching component was nestled pretty deep. I tried attaching it to what I thought was its ancestor, but no luck. At least the above answer worked.
              • 4. Re: Why am I not getting my event?
                Handycam Level 1
                Thanks, Hob, I needed to have it bubble.

                Amy, I couldn't do that since I needed the listener at the root of the app and the dispatching component was nestled pretty deep. I tried attaching it to what I thought was its ancestor, but no luck. At least the above answer worked.