Create a Menu that uses an Array data provider : Menu Model « Components « Flex






Create a Menu that uses an Array data provider

Create a Menu that uses an Array data provider
      
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
        
        import mx.controls.Menu;
        private function createAndShow():void {
            var myMenu:Menu = Menu.createMenu(null, menuData, true);
            myMenu.show(10, 10);
        }
        [Bindable]
        public var menuData:Array = [
            {label: "MenuItem A", children: [
                {label: "A-1", enabled: false},
                {label: "A-2", type: "normal"},
                {label: "A-3", type: "normal"},
                {label: "A-4", type: "normal"}]},
            {label: "MenuItem B", type: "check", toggled: true},
            {label: "MenuItem C", type: "check", toggled: false},
            {type:  "separator"},
            {label: "MenuItem D", children: [
                {label: "D-1", type: "radio",groupName: "g1"},
                {label: "D-2", type: "radio",groupName: "g1"},
                {label: "D-3", type: "radio",groupName: "g1"},                                            
                {label: "D-4", type: "radio",groupName: "g1"},
                {label: "D-5", type: "radio",groupName: "g1", toggled: true},
                {label: "D-6", type: "radio",groupName: "g1"}]}
        ];
      
    </mx:Script>
    <mx:Button x="300" y="10" label="Open Menu" click="createAndShow();" />
</mx:Application>

   
    
    
    
    
    
  








Related examples in the same category

1.Use to define the data for the Menu controlUse <mx:XML> to define the data for the Menu control
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