Flex中menu菜单

来源:互联网 发布:vb编程实例讲解 编辑:程序博客网 时间:2024/05/22 07:53
  Flex中生成菜单:
  1. <?xml version="1.0"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
  3.     layout="absolute">
  4.     <mx:Script>
  5.         <![CDATA[
  6.             import mx.controls.Menu;
  7.             // Method to create an Array-based menu. 
  8.             private function createAndShow():void {
  9.                 // The third parameter sets the showRoot property to false.
  10.                 // You must set this property in the createMenu method, 
  11.                 // not later.
  12.                 var myMenu:Menu = Menu.createMenu(null, menuData, true);//定义了一个menu
  13.                 myMenu.show(1010);//menu show的显示位置
  14.             }
  15.             // The Array data provider(数据提供)
  16.             [Bindable] 
  17.             public var menuData:Array = [
  18.                 {label: "MenuItem A", children: [//设置复选框
  19.                     {label: "SubMenuItem A-1", enabled: false},//表示是不可选的
  20.                     {label: "SubMenuItem A-2", type: "normal"//一般状态
  21.                     ]},//没设置选择type就没选择后的提示
  22.                 {label: "MenuItem B", type: "check", toggled: true},//toggled表示是否勾选
  23.                 {label: "MenuItem C", type: "check", toggled: false},
  24.                 {type: "separator"},//设置分割线
  25.                 {label: "MenuItem D", children: [
  26.                     {label: "SubMenuItem D-1", type: "radio"//表示同组单选的
  27.                         groupName: "g1"},
  28.                     {label: "SubMenuItem D-2", type: "radio"
  29.                         groupName: "g1", toggled: true}, 
  30.                     {label: "SubMenuItem D-3", type: "radio"
  31.                         groupName: "g1"
  32.                     ]} 
  33.                 ];
  34.         ]]>
  35.     </mx:Script>
  36.     <!-- Button control to create and open the menu. -->
  37.     <mx:Button x="300" y="10" 
  38.         label="Open Menu" 
  39.         click="createAndShow();"/>
  40. </mx:Application>