Create a Menu that uses an Array data provider
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
import mx.controls.Menu;
private function createAndShow():void {
var myMenu:Menu = Menu.createMenu(null, menuData, true);
myMenu.show(10, 10);
}
[Bindable]
public var menuData:Array = [
{label: "MenuItem A", children: [
{label: "A-1", enabled: false},
{label: "A-2", type: "normal"},
{label: "A-3", type: "normal"},
{label: "A-4", type: "normal"}]},
{label: "MenuItem B", type: "check", toggled: true},
{label: "MenuItem C", type: "check", toggled: false},
{type: "separator"},
{label: "MenuItem D", children: [
{label: "D-1", type: "radio",groupName: "g1"},
{label: "D-2", type: "radio",groupName: "g1"},
{label: "D-3", type: "radio",groupName: "g1"},
{label: "D-4", type: "radio",groupName: "g1"},
{label: "D-5", type: "radio",groupName: "g1", toggled: true},
{label: "D-6", type: "radio",groupName: "g1"}]}
];
</mx:Script>
<mx:Button x="300" y="10" label="Open Menu" click="createAndShow();" />
</mx:Application>
Related examples in the same category