Creating an undraggable TitleWindow container in Flex
Posted on 2008-08-28 00:43 OldHawk 阅读(666) 评论(0) 编辑 收藏 举报The following examples show how you can create an undraggable TitleWindow container by setting the isPopUp
property to false
on the TitleWindow instance.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/16/creating-an-undraggable-titlewindow-container-in-flex/ -->
<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>
<!-- http://blog.flexexamples.com/2008/08/16/creating-an-undraggable-titlewindow-container-in-flex/ -->
<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>
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/16/creating-an-undraggable-titlewindow-container-in-flex/ -->
<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 {
this.isPopUp = 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>
<!-- http://blog.flexexamples.com/2008/08/16/creating-an-undraggable-titlewindow-container-in-flex/ -->
<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 {
this.isPopUp = 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>