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