createPopUp:是上来先设置好弹出方式,然后在new出来一个TitleWindow的对象,然后通过此对象设置他的变现形式。
addPopUp:是先new出来对象,设置好表现形式,然后在选择弹出来的方式。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.managers.PopUpManagerChildList;
import mx.controls.Label;
import mx.events.CloseEvent;
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
private var titleWindow:TitleWindow;
private function init():void {
var label:Label = new Label();
label.text = "Hello world";
titleWindow = new TitleWindow();
titleWindow = TitleWindow(PopUpManager.createPopUp(this,TitleWindow,true));
titleWindow.title = "Custom title";
titleWindow.showCloseButton = true;
titleWindow.width = 240;
titleWindow.height = 180;
titleWindow.addChild(label);
titleWindow.addEventListener(CloseEvent.CLOSE, titleWindow_close);
PopUpManager.centerPopUp(titleWindow);
}
private function titleWindow_close(evt:CloseEvent):void {
PopUpManager.removePopUp(titleWindow);
}
protected function button1_clickHandler(event:MouseEvent):void
{
init();
}
]]>
</fx:Script>
<s:Button x="6" y="0" label="PopUpManager createPopUp方式 弹出窗口" width="375" height="36" click="button1_clickHandler(event)"/>
</s:Application>
留作参考,文章来源:http://hi.baidu.com/miracle5460/item/be9d74c37e3cba2c46d5c0e4