FLEX的menubar用外部xml做数据源.
mxml:
<?xml version="1.0" encoding="gb2312"?>
<mymenu label="all">
<menuitem label="软件介绍" data="软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍软件介绍"/>
<menuitem label="主要功能" data="主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能主要功能"/>
<menuitem label="使用方法一" data="使用方法一使用方法一使用方法一使用方法一"/>
<menuitem label="使用方法二" data="使用方法二使用方法二使用方法二使用方法二使用方法二"/>
<menuitem label="关于我们" data="关于我们关于我们关于我们关于我们"/>
<menuitem label="Menu6" data="top6"/>
<menuitem label="Menu7" data="top7"/>
<menuitem label="Menu8" data="top8"/>
<menuitem label="Menu9" data="top9"/>
<menuitem label="Menu10" data="top10"/>
</mymenu>
1
<?xml version="1.0" encoding="utf-8"?>
2
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="cargaMenu.send();">
3
<mx:HTTPService id="cargaMenu" showBusyCursor="true" method="POST" url="http://localhost/flex/menu.xml" useProxy="false" result="httpResult(event)" resultFormat="e4x">
4
</mx:HTTPService>
5
<mx:Script>
6
<![CDATA[
7
import mx.rpc.events.ResultEvent;
8
[Bindable]
9
public var datos:XMLList;
10
[Bindable]
11
private var listaMenu:XML;
12
[Bindable]
13
private var tipText:String;
14
private function httpResult(event:ResultEvent):void
15
{
16
//var listaMenu:XML = event.result as XML;
17
listaMenu= event.result as XML;
18
//datos = new XMLList(listaMenu.Menuitem);
19
}
20
import mx.events.MenuEvent;
21
private function menuHandler(event:MenuEvent):void {
22
tipText=event.item.@data;
23
}
24
]]>
25
</mx:Script>
26
<mx:HRule x="0" y="85" width="100%"/>
27
<mx:Label x="21" y="18" text="EHAI" width="131" height="67" fontSize="36" fontWeight="bold" color="#ffffff" alpha="0.96" enabled="true"/>
28
<mx:MenuBar x="19" y="98" labelField="@label" dataProvider="{listaMenu}" itemRollOver="menuHandler(event);" showRoot="false" textDecoration="underline" fontSize="14" fontWeight="bold"></mx:MenuBar>
29
<mx:Canvas x="160" y="9" width="627" height="68">
30
<mx:Image x="5" y="5" width="70" height="58"/>
31
<mx:Label x="95" y="7" fontSize="12" text="{tipText}" width="522" height="61"/>
32
</mx:Canvas>
33
</mx:Application>
34![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
XML:![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)