2 Replies Latest reply on Jan 17, 2011 9:34 AM by jfb00

    how to give link to submenu of the menubar Pls help me


      Dear Sir,


      I am new in Flex, i want to know that how can we give to link for
      child in menuBar, for new window open.


      I created one parent.mxml with menus and submenu's
      i created one component.mxml with different fields


      So i want to link component.mxml to one of the child menu.


      Vigin Kurakar

        • 1. Re: how to give link to submenu of the menubar Pls help me
          jfb00 Level 3


          In your menuBar you can set the itemClick event, then capture this event in AS like:



          In menuChange(event:MenuEvent) you can validate and show your component like:

            private function menuChange(event:MenuEvent):void
               if (event.label == "my option"){
                    //hide-show my component
               // Alert.show(event.item.@name, 'menuBar ItemClick Event' )





          • 2. Re: how to give link to submenu of the menubar Pls help me
            saisri2k2 Level 4
            <?xml version="1.0"?>
            <!-- Simple example to demonstrate the MenuBar control. -->
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initCollections();" >
                           import mx.collections.*;
                           import mx.controls.Alert;
                           import mx.events.MenuEvent;
                           public var menuBarCollection:XMLListCollection;
                           private var menubarXML:XMLList =
                                     <menuitem label="Menu1" data="top">
                                          <menuitem label="MenuItem 1-A" data="1A"/>
                                          <menuitem label="MenuItem 1-B" data="1B"/>
                                     <menuitem label="Menu2" data="top">
                                          <menuitem label="MenuItem 2-A" type="check"  data="2A"/>
                                          <menuitem type="separator"/>
                                          <menuitem label="MenuItem 2-B" >
                                               <menuitem label="SubMenuItem 3-A" type="radio"
                                                    groupName="one" data="3A"/>
                                               <menuitem label="SubMenuItem 3-B" type="radio"
                                                    groupName="one" data="3B"/>
                           // Event handler to initialize the MenuBar control.
                           private function initCollections():void {
                                menuBarCollection = new XMLListCollection(menubarXML);
                           // Event handler for the MenuBar control's itemClick event.
                           private function menuHandler(event:MenuEvent):void  {
                                // Don't open the Alert for a menu bar item that 
                                // opens a popup submenu.
                                /* if (event.item.@data != "top") {
                                     Alert.show("Label: " + event.item.@label + "\n" + 
                                          "Data: " + event.item.@data, "Clicked menu item");
                                }   */
                                var menuItem:String = event.item.@data;
                                     case "1A":Alert.show("1-A")
                                     case "2A":Alert.show("2A");// herer the 2A is in a different level altogether
                                     //go on like this
                 <mx:Panel title="MenuBar Control Example" height="75%" width="75%" 
                             paddingTop="10" paddingLeft="10">
                      <mx:Label width="100%" color="blue"
                                  text="Select a menu item."/>
                      <mx:MenuBar labelField="@label" itemClick="menuHandler(event);" 
                                     dataProvider="{menuBarCollection}" />


            somthing like this will work for you.


            ref: http://examples.adobe.com/flex3/componentexplorer/explorer.html


            If you have any trouble go to the above link and view the examples, you will get good idea on all of the components.