<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" height="600" width="600">
<mx:Script>
<![CDATA[
import mx.controls.*;
import mx.events.*;
private var myMenu:Menu;
// Initialize the Menu control, and specify it as the pop up object
// of the PopUpButton control.
private function initMenu():void {
myMenu = new Menu();
var dp:Object = [{label: "New Folder"}, {label: "Sent Items"},
{label: "Inbox"}];
myMenu.dataProvider = dp;
myMenu.selectedIndex = 0;
myMenu.addEventListener("change", changeHandler);
popB.popUpObject = myMenu;
popB.label = "Put in: " +
myMenu.getMenuItemAt(myMenu.selectedIndex).getProperty("label");
}
// Define the event listener for the Menu control's change event.
private function changeHandler(event:MenuEvent):void {
var label:String = event.menuItem.getProperty("label");
popTypeB.text=String("Moved to " + label);
//BUG!!! if you uncomment this, the menu will hide when you expect it to, otherwise it behaves strangely
//popB.label = "Put in: " + label;
popB.closePopUp ();
myMenu.selectedIndex = event.index;
}
]]>
</mx:Script>
<mx:VBox>
<mx:Label text="Main button mimics the last selected menuItem." />
<mx:PopUpButton id="popB" label="Edit"
creationComplete="initMenu();"
width="135" />
<mx:Spacer height="50" />
<mx:TextInput id="popTypeB" />
</mx:VBox>
</mx:Application>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

