Use to define the data for the Menu control : Menu Model « Components « Flex






Use to define the data for the Menu control

Use <mx:XML> to define the data for the Menu control
      
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
            import mx.controls.Menu;
            private function createAndShow():void {
                var myMenu:Menu = Menu.createMenu(null, myMenuData, false);
                myMenu.labelField="@label";
                myMenu.show(10, 10);
            }
          
    </mx:Script>
    <mx:XML format="e4x" id="myMenuData">
        <root>
            <menuitem label="MenuItem A">
                <menuitem label="SubMenuItem A-1" enabled="false" />
                <menuitem label="SubMenuItem A-2" />
                <menuitem label="SubMenuItem A-3" />
                <menuitem label="SubMenuItem A-4" />
                <menuitem label="SubMenuItem A-5" />
                <menuitem label="SubMenuItem A-6" />
                <menuitem label="SubMenuItem A-7" />
                <menuitem label="SubMenuItem A-8" />
                <menuitem label="SubMenuItem A-9" />
            </menuitem>
            <menuitem label="MenuItem B" type="check" toggled="true" />
            <menuitem label="MenuItem C" type="check" toggled="false" />
            <menuitem type="separator" />
            <menuitem label="MenuItem D">
                <menuitem label="SubMenuItem D-1" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-2" type="radio" groupName="one" toggled="true" />
                <menuitem label="SubMenuItem D-3" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-4" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-5" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-6" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-7" type="radio" groupName="one" />
                <menuitem label="SubMenuItem D-8" type="radio" groupName="one" />
            </menuitem>
        </root>
    </mx:XML>
    <mx:VBox>
        <mx:Button id="myButton" label="Open Menu" click="createAndShow();" />
    </mx:VBox>
</mx:Application>

   
    
    
    
    
    
  








Related examples in the same category

1.Create a Menu that uses an Array data providerCreate a Menu that uses an Array data provider
2.Use XMLListCollection as the data model for MenuBarUse XMLListCollection as the data model for MenuBar
3.Provide Data for MenusProvide Data for Menus
4.Array DataProvider for MenuArray DataProvider for Menu
5.An XML menu data provider with iconsAn XML menu data provider with icons
6.The dataProvider property is the default property of the MenuBar controlThe dataProvider property is the default property of the MenuBar control
7.Create MenuBar from XMLListCreate MenuBar from XMLList
8.Create menu from XMLCreate menu from XML
9.Create Menu from ArrayCreate Menu from Array
10.Define XML or XMLList object as a direct child of the Define XML or XMLList object as a direct child of the <mx:MenuBar>
11.Dynamically Populate MenusDynamically Populate Menus
12.Model With MenuModel With Menu