Use PopUpManager to add and remove TitleWindow
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="600"
width="600">
<mx:Script>
import mx.containers.TitleWindow;
import flash.events.*;
import mx.managers.PopUpManager;
import mx.controls.Button;
import mx.core.IFlexDisplayObject;
public var myTitleWindow:TitleWindow = new TitleWindow();
public function openWindow(event:MouseEvent):void {
myTitleWindow = new TitleWindow();
myTitleWindow.title = "Window Title";
myTitleWindow.width= 220;
myTitleWindow.height= 150;
var btn1:Button = new Button();
btn1.label="close";
btn1.addEventListener(MouseEvent.CLICK, closeTitleWindow);
myTitleWindow.addChild(btn1);
PopUpManager.addPopUp(myTitleWindow, this, true);
}
public function closeTitleWindow(event:MouseEvent):void {
PopUpManager.removePopUp(event.currentTarget.parent);
}
</mx:Script>
<mx:Button label="Open Window" click="openWindow(event);" />
</mx:Application>
Related examples in the same category