Set popup menu selected item : Popup Menu « Components « Flex






Set popup menu selected item

Set popup menu selected item
     
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="600"
    width="600" creationComplete="initData();">
    <mx:Script>
        
        import mx.events.*;
        import mx.controls.*;
        private function initData():void {
            Menu(p1.popUp).selectedIndex=2;
        }
        public function itemClickHandler(event:MenuEvent):void {
            Alert.show("itemClick event label: " + event.label  + " \nindex: " + event.index
                    + " \nitem.label: " + event.item.label
                    + " \nitem.data: " + event.item.data);
        }
        public function clickHandler(event:MouseEvent):void {
            Alert.show(" Click Event currentTarget.label: " + event.currentTarget.label);
        }
        [Bindable]
        public var menuDP:Array = [
            {label: "A", data: "a"},
            {label: "B", data: "b"},
            {label: "C", data: "c"},
            {label: "D", data: "d"},
            {label: "E", data: "e"}
        ];
      </mx:Script>
    <mx:PopUpMenuButton id="p1" showRoot="true" dataProvider="{menuDP}" click="clickHandler(event)" itemClick="itemClickHandler(event);" />
</mx:Application>

   
    
    
    
    
  








Related examples in the same category

1.Create and show popup menuCreate and show popup menu
2.Bind Form data to popup menuBind Form data to popup menu
3.PopUp Menu Button EventsPopUp Menu Button Events