浏览 9384 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-11-27
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对象与弹出方式的先后顺序。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |