Flex menubar

<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600">


<fx:Script>
<![CDATA[
import mx.events.MenuEvent;

private function menuClickHandle(e:MenuEvent):void{
switch(e.label){
case "submenu1":currentState="index1";break;
case "submenu2":currentState="index2";break;
case "submenu3":currentState="index3";break;
case "submenu4":currentState="index4";break;
case "submenu5":currentState="index5";break;
}
}

]]>
</fx:Script>


<s:states>
<s:State name="index1" />
<s:State name="index2" />
<s:State name="index3" />
<s:State name="index4" />
<s:State name="index5" />
</s:states>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:XMLList id="myXMLList">
<item id="menu1">
<item id="submenu1" type="radio" groupName1="one" />
<item id="submenu2" type="radio" groupName2="one" />
</item>
<item id="menu2" />
<item id="menu3" />
<item id="menu4" >
<item id="submenu3" type="radio" groupName="two" />
<item id="submenu4" type="radio" groupName="two" selected="true" />
<item id="submenu5" type="radio" groupName="two" />
</item>
</fx:XMLList>
</fx:Declarations>

<mx:MenuBar y="24" id="myMenubar" dataProvider="{myXMLList}" labelField="@id" width="293" horizontalCenter="0" change="menuClickHandle(event)" change.index2="menuClickHandle(event)"></mx:MenuBar>

<s:Group id="group1" includeIn="index1" x="{myMenubar.x}" y="{myMenubar.y+myMenubar.height}">
<s:Rect width="{myMenubar.width}" height="248" alpha="0.5">
<s:fill>
<mx:SolidColor color="#000000" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="group2" includeIn="index2" x="{myMenubar.x}" y="{myMenubar.y+myMenubar.height}">
<s:Rect width="{myMenubar.width}" height="248" alpha="0.5">
<s:fill>
<mx:SolidColor color="#f5e532" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="group3" includeIn="index3" x="{myMenubar.x}" y="{myMenubar.y+myMenubar.height}">
<s:Rect width="{myMenubar.width}" height="248" alpha="0.5">
<s:fill>
<mx:SolidColor color="#bdf531" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="group4" includeIn="index4" x="{myMenubar.x}" y="{myMenubar.y+myMenubar.height}">
<s:Rect width="{myMenubar.width}" height="248" alpha="0.5">
<s:fill>
<mx:SolidColor color="#d731f5" />
</s:fill>
</s:Rect>
</s:Group>
</s:Application>

XMLList组件与XML组件不同点在于XML组件必须要有根结点。

1、菜单项的type属性为"radio",表示该菜单项为单选菜单项。

2、mx:MenuBar的labelField属性为"@id",表示菜单项的显示内容光焕发为数据集中的"id"属性。

3、horizontalCenter属性为"0",表示菜单居中显示。

4、includeIn属性是添加元素(相当于AddChild),excludeFrom属性是删除元素
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值