3 Replies Latest reply on Sep 28, 2008 9:02 AM by Peter Lorent

    passing Events

    gerraIrkutsk-vtxlyW
      How I can pass event from component to application or to another component? In my example event "eventA" is listened in component A.mxml but it don't hear in application Events.mxml.
        • 1. Re: passing Events
          Peter Lorent Level 2
          Expected behaviour. You are firing the event from the component BEFORE the creationComplete event fires of the main application.
          Furthermore, since you register the event on the main application using this.addEventListener you are registering for an event 'eventA' from any component in your application and you need to let eventA bubble. If you want to register for an eventA from A you should use canvasA.addEventListener("eventA", messageFromA);
          • 2. Re: passing Events
            gerraIrkutsk-vtxlyW Level 1
            Thanks! If I register event listeners for canvasA - canvasA.addEventListener("eventA", messageFromA), then it works and listens events from canvasA. If I want to listen event from anywhere - this.addEventListener("eventA", messageFromA), then it is not working (I tried to run event over Button click comand - code see below). Can I hear events from anyware in application or some component?
            • 3. Re: passing Events
              Peter Lorent Level 2
              If you want to use addEventListener("eventA", messageFromA); in Events.mxml (the main application) then you must set the second parameter (bubbles) of the event to true.

              dispatchEvent(new Event("eventA", true));