发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
使用ActionScript 为MenuBar 控件的dataProvider 属性分配一个Collection 对象(例如
ArrayCollection 或者XMLListCollection)
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp(event)">
<mx:MenuBar id="menu" dataProvider="{menu_dp}"/>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var menu_dp:ArrayCollection;
private function initApp(evt:FlexEvent):void {
var temp:Array = new Array();
var subNodes:ArrayCollection = new ArrayCollection([
{label:"New"},{label:"Open"},{label:"Close",enabled:false}
]);
temp.push({label:"File",children:subNodes});
temp.push({label:"Edit"});
temp.push({label:"Source"});
subNodes = new ArrayCollection( [
{label:"50%", type:"radio", groupName:"one"},
{label:"100%", type:"radio",groupName:"one",selected:true},
{label:"150%",type:"radio",groupName:"one"}
]);
temp.push({label:"View",children:subNodes});
menu_dp = new ArrayCollection(temp);
}
]]>
</mx:Script>
</mx:Application>
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。