Using PopUpButton to display an optional menu
<?xml version='1.0' encoding='UTF-8'?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.controls.Alert;
import mx.events.*;
import mx.controls.Menu;
public var menuItems:Object = [{label:'One'},{label:'Two'},{label:'Three'}];
public var thisMenu:Menu = Menu.createMenu(null,menuItems,false);
public function handleItemClick(event:MenuEvent):void{
menuBtn.label = event.label;
}
</mx:Script>
<mx:PopUpButton id="menuBtn"
creationComplete="thisMenu.addEventListener('itemClick',handleItemClick);"
popUp="{thisMenu}" />
</mx:Application>
Related examples in the same category