Createpopup: first set the pop-up mode, then a new titlewindow object, and then set its representation through this object.
Addpopup: First New the object, set the representation, and then play it out in the selection.
Pay attention to the order of new objects and pop-up methods!
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Http://yecon.blog.hexun.com/29989820_d.html -->
<! -- Http://www.slsay.com -->
<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>
-----------------------------------------------------------------
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Http://yecon.blog.hexun.com/29989820_d.html -->
<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>