Flex: difference between createpopup and addpopup of popupmanager

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.