When the menu is defined in XML you need traverse the tree that way as
opposed to the way you were doing. It's in the Flex Application
Development PDF under Menu Controls.

Thanks,
Sof

--- In flexcoders@yahoogroups.com, "Jordan Snyder" <[EMAIL PROTECTED]>
wrote:
>
> That did it!  Thank you!
>
> I was apparently going down the wrong path, because when I traced the
> event object itself, I was not seeing a "menuItem" property...so it's
> just magically there.  Why would that property not show up?
>
> Cheers
>
> On 4/22/06, sof4real03 <[EMAIL PROTECTED]> wrote:
> > Try accessing your label attribute as follows:
> >
> > [EMAIL PROTECTED] and then you should be able to retrieve the
> > value.
> >
> > Let me know if tht works for you.
> > -Sof
> >
> >
> > --- In flexcoders@yahoogroups.com, "Jordan Snyder" <jordan.lists@>
> > wrote:
> > >
> > > Hello,
> > >
> > > I'm using Flex 2 Beta 2, and I'm trying to catch MenuBar events.
> > >
> > > I've already been through the workarounds in order to display
E4X XML
> > > dataproviders correctly, ie, using showRoot="false",
> > > labelField="@label", etc.
> > >
> > > However, whenever a MenuBar event fires, the event object does not
> > > contain a menuItem property.  I can trace the event object and see
> > > that it contains no menuItem.  Here is my code, in case I've missed
> > > something silly.
> > >
> > >
> > >
> > > mx:Script><![CDATA[
> > >   import mx.managers.PopUpManager;
> > >   import mx.controls.Menu;
> > >   import mx.controls.MenuBar;
> > >         import mx.events.MenuEvent;
> > >
> > >
> > >         private function changeEvt(event:MenuEvent):void {
> > >             flash.util.trace("crazy"+event);
> > >             if(event.menuItem.attributes.label == "Settings...") {
> > >              showSettings();
> > >             }
> > >         }
> > >
> > >
> > >         private function showSettings():void {
> > >             // Create the TitleWindow container.
> > >             var settingsWindow:IFlexDisplayObject =
> > > PopUpManager.createPopUp(this,
> > > SettingsMenu, false);
> > >         }
> > >
> > >  ]]>
> > >  </mx:Script>
> > >
> > >
> > >
> > > <mx:MenuBar x="0" y="0" width="1024" height="20" id="FileBar"
> > > change="changeEvt(event)" labelField="@label" showRoot="false">
> > >   <mx:dataProvider>
> > >           <mx:XML format="e4x">
> > >     <menuitem label="File">
> > >                  <menuitem label="Exit" />
> > >              </menuitem>
> > >              <menuitem label="Edit">
> > >               <menuitem label="Mode">
> > >                <menuitem label="** Mode"/>
> > >                <menuitem label="** Mode"/>
> > >               </menuitem>
> > >               <menuitem label="Users..." />
> > >               <menuitem label="IP Address List..." />
> > >               <menuitem label="Settings..." />
> > >              </menuitem>
> > >              <menuitem label="View">
> > >               <menuitem label="Logs..." />
> > >               <menuitem label="Reports..." />
> > >              </menuitem>
> > >              <menuitem label="Window">
> > >               <menuitem label="***" />
> > >               <menuitem label="***" />
> > >              </menuitem>
> > >              <menuitem label="Help">
> > >               <menuitem label="*** Help..." />
> > >               <menuitem label="Support" />
> > >               <menuitem label="Check for Updates..." />
> > >               <menuitem label="About ****" />
> > >              </menuitem>
> > >
> > >           </mx:XML>
> > >   </mx:dataProvider>
> > >
> > >  </mx:MenuBar>
> > >
> > > The trace shows this:
> > >
> > > crazy[Event type="change" bubbles=false cancelable=true
eventPhase=2]
> > >
> > >
> > >
> > > Is there a workaround?  Is anyone getting MenuBar events to work in
> > Beta 2?
> > >
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to