Dynamically Populate Menus
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp(event)">
<mx:MenuBar id="menu" dataProvider="{menu_dp}"/>
<mx:Script>
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:"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>
Related examples in the same category