Define properties and reference in actionscript : Menu « Components « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Components » MenuScreenshots 
Define properties and reference in actionscript
Define properties and reference in actionscript
   
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF">
    <mx:XMLListCollection id="myMenuData">
        <mx:XMLList>
            <menuitem label="File">
                <submenu label="New" />
                <submenu label="Open">
                    <submenu label="Doc" openType="1" />
                    <submenu label="Pdf" openType="2" toggled="true" />
                </submenu>
            </menuitem>
        </mx:XMLList>
    </mx:XMLListCollection>
    <mx:Script>
        
        import mx.controls.Alert;
        import mx.controls.Menu;
        import mx.events.MenuEvent;
        private function showMenu():void
        {
            var myMenu:Menu = Menu.createMenu(myButton, myMenuData);
            myMenu.labelField="@label";
            myMenu.addEventListener("itemClick",handleMenuClick);
            myMenu.show();
        }
        private function handleMenuClick(evt:MenuEvent):void
        {
            mx.controls.Alert.show(evt.item.@label);
            lastEvent.text = "Selection:" + evt.item.@label + ", Position: " + evt.index + " Type:" + evt.item.@openType;
        }
      
    </mx:Script>
    <mx:Button id="myButton" label="Display Menu" click="showMenu()" />
    <mx:Label id="lastEvent" />
</mx:Application>

   
    
    
  
Related examples in the same category
1.Add icons to menuAdd icons to menu
2.Add submenu to submenuAdd submenu to submenu
3.Show menuShow menu
4.Set menu to toggle menu itemSet menu to toggle menu item
5.Radio button menu itemsRadio button menu items
6.Using a nested array to drive a menu
7.CheckBox MenuItemCheckBox MenuItem
8.Creating a model that a menu uses to drive its display
9.Creating a menu from scratchCreating a menu from scratch
10.Compact way to initialize and display the menu all at onceCompact way to initialize and display the menu all at once
11.Set Menu style for disabled colorSet Menu style for disabled color
12.Show Menu at positioinShow Menu at positioin
13.Disable a menu itemDisable a menu item
14.Model for MenuModel for Menu
15.Add click listener to MenuAdd click listener to Menu
16.Submenu and radio button menuSubmenu and radio button menu
17.CheckBox menuCheckBox menu
18.Menu Control style settingMenu Control style setting
19.Adding icon to MenuitemAdding icon to Menuitem
20.Get clicked menu item index, label, toggle stateGet clicked menu item index, label, toggle state
21.Menu item click handlerMenu item click handler
22.Put Menu, TextInput and Button to ControlBarContentPut Menu, TextInput and Button to ControlBarContent
23.Creating a simple Menu controlCreating a simple Menu control
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.