4 Replies Latest reply on Jun 8, 2009 6:45 AM by BennyBeta

    How to catch event?




      I usually use event connected with visual control, but now I would like to manually dispatch event, when I succesfully receive data from my mySQL database, and change a couple of visual controls in a few custom components. Do you know any example in the net, or could give me some tips?


      Best regards.

        • 1. Re: How to catch event?
          Michael Borbor Level 4

          Read the Flex 3 docs about Dispatching Custom events.

          • 2. Re: How to catch event?
            BennyBeta Level 4

            To dispatch an event you want a component that implements IEventDispatcher or extends EventDispatcher.


            To dispatch an event from such a component:


            dispatchEvent( new Event( "eventName" ) );


            To add a listener for the event:


            dispatcher.addEventListener( "eventName", eventHandlerFunction );


            Let me know if that helps...

            Ben Edwards

            • 3. Re: How to catch event?
              TodLoch Level 1

              My english isn't so good, so please correct me if I'm wrong:


              Currently, I have application in which I have 2 components, let's name it Comp1 and Comp2 (containing several standard controls like text input, label, combobox etc.)  and 1 module loaded (let's name it Mod1) dynamically into one of that component (Comp2). In this module I have another component -> Comp3, with combobox. When I change the value of this combobox, I connect to mySQL database, get the data and ... I would like to change a several controls in Comp1.




              First of all, I should create a components Comp1, Comp2 and Comp3 which implements IEventDispatcher.

              In Comp3 I have the data from my database, and there I should dispatch event and place my data in event object.

              In Comp1 I should add listener for this event using addEventListener()


              Am I right?



              • 4. Re: How to catch event?
                BennyBeta Level 4

                Yes, it sounds like you are on the right track.  Mod1/Comp3 will dispatch events and Comp1/Comp2 will listen for them with addEventListener().


                Good work.


                Ben Edwards

                1 person found this helpful