PopUpManager--createPopUp与addPopUp区别
addPopUp代码:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()"> <mx:Script> <![CDATA[ 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.title = "Custom title"; titleWindow.showCloseButton = true; titleWindow.width = 240; titleWindow.height = 180; titleWindow.addEventListener(CloseEvent.CLOSE, titleWindow_close); titleWindow.addChild(label); PopUpManager.addPopUp(titleWindow, this, true); PopUpManager.centerPopUp(titleWindow); } private function titleWindow_close(evt:CloseEvent):void { PopUpManager.removePopUp(titleWindow); } ]]> </mx:Script> <mx:Button label="Launch TitleWindow" click="init()" /></mx:Application>
?
createPopUp代码:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()"> <mx: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); } ]]> </mx:Script> <mx:Button label="Launch TitleWindow" click="init()" /></mx:Application>
?createPopUp:是上来先设置好弹出方式,然后在new出来一个TitleWindow的对象,然后通过此对象设置他的变现形式。
addPopUp:是先new出来对象,设置好表现形式,然后在选择弹出来的方式。
一定要注意new对象与弹出方式的先后顺序。