Model With Menu : Menu Model « Components « Flex






Model With Menu

Model With Menu
      
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



<!-- dpcontrols\ModelWithMenu.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns="*">
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <fx:Script> 
         
        import mx.controls.Menu; 
        public var productMenu:Menu; 
        public function initMenu(): void { 
            productMenu = Menu.createMenu(null, Products.Department); 
            productMenu.setStyle("disabledColor", 0xCC3366); 
            productMenu.show(10,10); 
        } 
      
    </fx:Script>
    <fx:Declarations>
        <fx:Model id="Products">
            <Root>
                <Department label="Toys">
                    <children label="Teddy Bears" />
                    <children label="Action Figures" />
                    <children label="Building Blocks" />
                </Department>
                <Department label="Kitchen">
                    <children label="Electronics">
                        <children label="Crock Pot" />
                        <children label="Panini Grill" />
                    </children>
                    <children label="Cookware">
                        <children label="Grill Pan" />
                        <children label="Iron Skillet" enabled="false" />
                    </children>
                </Department>
                <!-- The items in this entry are bound to the form data -->
                <Department label="{menuName.text}">
                    <children label="{item1.text}" />
                    <children label="{item2.text}" />
                    <children label="{item3.text}" />
                </Department>
            </Root>
        </fx:Model>
    </fx:Declarations>
    <s:Button label="Show Products" click="initMenu()" />
    <!--
        If you change the contents of the form, the next time you display the
        Menu, it will show the updated data in the last main menu item.
    -->
    <mx:Form>
        <mx:FormItem label="Third Submenu title">
            <s:TextInput id="menuName" text="Clothing" />
        </mx:FormItem>
        <mx:FormItem label="Item 1">
            <s:TextInput id="item1" text="Sweaters" />
        </mx:FormItem>
        <mx:FormItem label="Item 2">
            <s:TextInput id="item2" text="Shoes" />
        </mx:FormItem>
        <mx:FormItem label="Item 3">
            <s:TextInput id="item3" text="Jackets" />
        </mx:FormItem>
    </mx:Form>
</s: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 to define the data for the Menu controlUse <mx:XML> to define the data for the Menu control
3.Use XMLListCollection as the data model for MenuBarUse XMLListCollection as the data model for MenuBar
4.Provide Data for MenusProvide Data for Menus
5.Array DataProvider for MenuArray DataProvider for Menu
6.An XML menu data provider with iconsAn XML menu data provider with icons
7.The dataProvider property is the default property of the MenuBar controlThe dataProvider property is the default property of the MenuBar control
8.Create MenuBar from XMLListCreate MenuBar from XMLList
9.Create menu from XMLCreate menu from XML
10.Create Menu from ArrayCreate Menu from Array
11.Define XML or XMLList object as a direct child of the Define XML or XMLList object as a direct child of the <mx:MenuBar>
12.Dynamically Populate MenusDynamically Populate Menus