1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp(event)">
<mx:MenuBar id="menuBar" dataProvider="{menu_dp}"
click="menuClique(menuBar.selectedIndex)"
itemClick="handleMenuClick(event)"/>
<mx:Script>
<![CDATA[
import mx.events.MenuEvent;
import mx.controls.Alert;
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:"Vue 1",children:subNodes});
temp.push({label:"Vue2"});
temp.push({label:"Vue3"});
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:"Vue4",children:subNodes});
menu_dp = new ArrayCollection(temp);
}
private function handleMenuClick(evt:MenuEvent):void {
this.disp0_lbl.text = evt.item.label + " was selected";
}
private function menuClique(index:int){
var n:int = menuBar.getMenuAt(index).numChildren
if( n == 0){
Alert.show("Le menu "+(index+1)+" a été selectionné");
}
}
]]>
</mx:Script>
<mx:Label id="disp0_lbl"/>
</mx:Application> |
Partager