flex中popupButton.mxml
<?xml version="1.0" encoding="utf-8"?>
<!--http://www.javaeye.com/topic/210348-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="absolute">
<mx:Style>
Application{
fontSize:12;
backgroundGradientColors: #c0c0c0, #c0c0c0;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.containers.Panel;
import mx.controls.Alert;
import mx.events.DropdownEvent;
private var panel:Panel;
private function initApp():void {
panel = new Panel(); //声明新的Panel
panel.title = "panel";
panel.width = 200;
panel.height = 200;
popBtn.popUp = panel; //指定popUp目标对象
popBtn.addEventListener(DropdownEvent.CLOSE,closeHandler); //
popBtn.open(); //将窗口弹出
}
private function closeHandler(evt:DropdownEvent):void{
Alert.show("关闭窗口");
}
]]>
</mx:Script>
<mx:PopUpButton id="popBtn" label="弹出" width="135" x="23" y="23"/>
</mx:Application>