《Flex企业应用开发实战》迷你书电子版 网址
网址:http://wenku.baidu.com/view/48b78d1755270722192ef7b6.html
Flex制作导航菜单
文章来源于:http://blog.sina.com.cn/s/blog_551f08ce0100c3eg.html
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="middle">
<mx:Script>
<![CDATA[
import mx.events.MenuEvent;
private function menuClickHandle(e:MenuEvent):void {
if (e.label == "menu1")
currentState = "index1";
else if (e.label == "childmenu1")
currentState = "index2";
else if (e.label == "childmenu2")
currentState = "index3";
else if (e.label == "childmenu3")
currentState = "index4";
else if (e.label == "childmenu4")
currentState = "index5";
else if (e.label == "childmenu5")
currentState = "index6";
}
]]>
</mx:Script>
<!--定义切换效果-->
<mx:transitions>
<!--可以重复-->
<mx:Transition id="myTransition1" fromState="*" toState="index1">
<mx:Parallel target="{myVBox1}">
<mx:WipeDown duration="2000"/>
<mx:Dissolve alphaFrom="0.0" alphaTo="1.0" duration="2000"/>
</mx:Parallel>
</mx:Transition>
</mx:transitions>
<mx:states>
<!--可以重复-->
<mx:State name="index1"> <!--新建“index1”状态-->
<mx:AddChild position="lastChild">
<!--添加VBox组件,组件颜色为“#FFFFFF”,透明度为0.5-->
<mx:VBox id="myVBox1" x="{myMenuBar.x}" y="{myMenuBar.y+myMenuBar.height}" width="{myMenuBar.width}"
height="248" backgroundColor="#FFFFFF" backgroundAlpha="0.5">
</mx:VBox>
</mx:AddChild>
</mx:State>
<mx:State name="index2"> <!--新建“index2”状态-->
<mx:AddChild position="lastChild">
<!--添加VBox组件,组件颜色为“#F5E531”,透明度为0.5-->
<mx:VBox id="myVBox2" x="{myMenuBar.x}" y="{myMenuBar.y+myMenuBar.height}" width="{myMenuBar.width}"
height="248" backgroundColor="#F5E531" backgroundAlpha="0.5">
</mx:VBox>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:XMLList id="myXMLList">
<menuitem id="menu1"/>
<menuitem id="menu2">
<menuitem id="childmenu1" type="radio" groupName="one"/>
<menuitem id="childmenu2" type="radio" groupName="one"/>
</menuitem>
<menuitem id="menu3">
<menuitem id="childmenu3" type="radio" groupName="two"/>
<menuitem id="childmenu4" type="radio" groupName="two"/>
<menuitem id="childmenu5" type="radio" groupName="two"/>
</menuitem>
</mx:XMLList>
<mx:MenuBar id="myMenuBar" dataProvider="{myXMLList}" labelField="@id" showRoot="false" width="560"
horizontalCenter="0" y="24" change="menuClickHandle(event)" fontSize="12"/>
</mx:Application>