7 Replies Latest reply on Jan 4, 2007 6:28 AM by Newsgroup_User

    dispatchEvent How To

    enfantterrible-tijzQ7
      Does anyone know how I can dispatch an event to a menuBar
        • 1. Re: dispatchEvent How To
          _Albertx_ Level 1
          there is a method called "dispatchEvent". With this you can dispatch all events you want.

          Take a look at the ActionScript Help in Flash.
          • 2. Re: dispatchEvent How To
            Level 7
            > there is a method called "dispatchEvent". With this you can
            > dispatch all events you want.

            Agreed. This method belongs to the EventDispatcher and
            UIEventDispatcher classes, both of which are available in the Components
            Language Reference in the Help panel. My personal preference is
            EventDispatcher.

            Here's a brief look at how you might use it.

            http://www.quip.net/blog/2006/flash/actionscript-20/how-to-raise-events-eventdispatcher


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: dispatchEvent How To
              enfantterrible-tijzQ7 Level 1
              I have and I've played around with the code for 4 - 5 hours and I've googled it and yahoo'd etc...

              I can dispatch events and the listener responds but I'm not able to send menu item attributes properly for the listner to determine which menu item I'm dispatching via actionscript.

              I've included the code to my test file (I've been playing around with many inteneratins of the "myItem_obj" properties.

              Thanks for the help!!!
              • 4. Re: dispatchEvent How To
                Level 7
                enfantterrible,

                >> Does anyone know how I can dispatch an event
                >> to a menuBar

                > I can dispatch events and the listener responds but I'm
                > not able to send menu item attributes properly for the
                > listner to determine which menu item I'm dispatching via
                > actionscript.

                Help me understand what you're trying to do. In your first question,
                you're talking about dispatching an event *to* a menuBar -- but events are
                simply dispatched to the open air, so to speak. They're not channeled in
                any particular direction ... they're simply dispatched, and you can write
                listeners to listen for them.

                Events raised by v2 Components generally do point to themselves. I'm
                looking at the Menu.menuShow event, for example (Components Language
                Reference) and see that the object sent when the event is dispatched. This
                event object contains two identifying properties, menuBar and menu, either
                of which might be what you're after.


                David Stiller
                Adobe Community Expert
                Dev blog, http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Re: dispatchEvent How To
                  enfantterrible-tijzQ7 Level 1
                  What I'm trying to do is the following:

                  I have an application that is made up of several modules each running in window comonents, every application running in a window has a menuBar where the user can select which module to open. The menuBar listener then updates every instance of every menuBar with the windows thar are open so that the user can toggle between all open windows easily.

                  I would like to be able to start other applications via actionscript so that an open application can access data in another application that might not be open yet.

                  As you can see from my little test app I'm able to dispatch menuBar events and have a listnener listen to those dispatched events. my problem is sending the menuItem attributes to the listener since "I believe" the menuBar/menus are made up of xml elements.

                  Thanks for the help!!!!!
                  • 6. Re: dispatchEvent How To
                    enfantterrible-tijzQ7 Level 1
                    Every once in a while... ok ok ok, often; I come across a problem that makes me think that perhaps I should be flipping burgers;

                    The solution to my problem is: testBar_mb.dispatchEvent({type:"change", target:testBar_mb, menuItem:fileMenu.test4});

                    The above eventDispatcher sends to my listner the menu attributes it needs.

                    Thanks for everyones help!!!
                    • 7. Re: dispatchEvent How To
                      Level 7
                      enfantterrible,

                      > Every once in a while... ok ok ok, often; I come across
                      > a problem that makes me think that perhaps I should be
                      > flipping burgers;

                      Hahaha ... happens to all of us! :) Glad you figured it out.


                      David Stiller
                      Adobe Community Expert
                      Dev blog, http://www.quip.net/blog/
                      "Luck is the residue of good design."