Mega Code Archive

 
Categories / Flex / Data Model
 

Method to create an Array-based menu

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">     <mx:Script>          import mx.controls.Menu;     private function buildDisplay():void {         var testMenu:Menu = Menu.createMenu(null, menuDataProvider, true);         testMenu.show(20, 20);     }     [Bindable]     public var menuDataProvider:Array = [         {label: "File", children: [                 {label: "Save", enabled: false},                 {label: "Open", type: "normal"}]},         {label: "Type", children: [                 {label: "Text", type: "radio",groupName: "group1"},                 {label: "Image", type: "radio",groupName: "group1", toggled: true},                 {label: "XML", type: "radio",groupName: "group1"}]},         {label: "Save As", type: "check", toggled: true},         {label: "Doc", type: "check", toggled: false}     ];        </mx:Script>     <mx:Button x="250" y="10" label="Menu" click="buildDisplay();"/> </mx:Application>