本文共 2386 字,大约阅读时间需要 7 分钟。
- <?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>
转载于:https://blog.51cto.com/daheyuan/1141808