Flex中通过isPopUp属性创建一个不可拖动TitleWindow的例子

main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="PopUpManager_TitleWindow_isPopUp_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.containers.TitleWindow;
            import mx.managers.PopUpManager;

            private var titleWin:MyTitleWin;

            private function launch():void {
                titleWin = PopUpManager.createPopUp(this, MyTitleWin, true) as MyTitleWin;
                PopUpManager.centerPopUp(titleWin);
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Button id="btn"
                label="Launch TitleWindow PopUp"
                click="launch();" />
    </mx:ApplicationControlBar>

</mx:Application>


MyTitleWin.mxml
 <?xml version="1.0" encoding="utf-8"?>
 <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="absolute"
        showCloseButton="true"
        title="TitleWindow"
        width="300"
        height="200"
        close="titleWin_close(event);">

    <mx:Script>
        <![CDATA[
            import mx.core.IFlexDisplayObject;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            private function titleWin_close(evt:CloseEvent):void {
                PopUpManager.removePopUp(evt.target as IFlexDisplayObject);
            }

            private function checkBox_change(evt:Event):void {
               [color=red] this.isPopUp[/color] = checkBox.selected;
            }
        ]]>
    </mx:Script>

    <mx:Label text="Drag this window"
            horizontalCenter="0"
            verticalCenter="0" />

    <mx:ControlBar>
        <mx:CheckBox id="checkBox"
                label="isPopUp:"
                labelPlacement="left"
                selected="true"
                change="checkBox_change(event);" />
    </mx:ControlBar>

 </mx:TitleWindow>


解释:
public static function createPopUp(parent:DisplayObject, className:Class, modal:Boolean = false, childList:String = null, moduleFactory:IFlexModuleFactory = null):IFlexDisplayObject
参数 
1、parent:DisplayObject — DisplayObject,用于确定要使用 SystemManager 的哪些层,以及(可选)确定居中新的顶级窗口所用的参考点。它可能并非弹出窗口的实际父项,因为所有弹出窗口都以 SystemManager 为父项。 
 
2、className:Class — 要为弹出窗口创建的对象的类。该类必须实现 IFlexDisplayObject。 
 
3、modal:Boolean (default = false) — 如果为 true,则该窗口为模态窗口,也就是说在删除该窗口之前,用户将无法与其他弹出窗口交互。 
 
4、childList:String (default = null) — 要将弹出窗口添加到的子项列表。PopUpManagerChildList.APPLICATION、PopUpManagerChildList.POPUP 或 PopUpManagerChildList.PARENT(默认)中的任意一项。 
 
5、moduleFactory:IFlexModuleFactory (default = null) — 此弹出窗口应在其中查找其嵌入字体和样式管理器的 moduleFactory。 

你可能感兴趣的:(TitleWindow,PopUpManager)