References: http://help.adobe.com/en_US/flex/using/WS6c678f7b363d5da52e8f1ca1124a0430dcf-8000.html
Pop-up code
<? XML version = "1.0"?> <! -- Containers \ spark \ mycomponents \ myloginform. mxml --> <s: titlewindow xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: MX = "Library: // ns.adobe.com/flex/mx" xmlns: S = "Library: // ns.adobe.com/flex/spark "Close =" handlecloseevent (); "> <s: layout> <s: verticallayout/> </S: layout> <FX: SCRIPT> <! [CDATA [import MX. managers. popupmanager; // handle the close button and cancel button. private function handlecloseevent (): void {popupmanager. removepopup (this);} // handle the OK button. private function processlogin (): void {// check credentials (not shown) then remove pop up. popupmanager. removepopup (this);}]> </FX: SCRIPT> <s: Form> <s: formitem label = "User Name"> <! -- Get the elements of the parent program --> <s: textinput id = "username" width = "100%" text = "{parentapplication. login. label} "/> </S: formitem> <s: formitem label =" password "> <s: textinput id = "password" displayaspassword = "true" width = "100%"/> </S: formitem> </S: Form> <s: hgroup> <s: button label = "OK" Click = "processlogin ();"/> <s: button label = "cancel" Click = "handlecloseevent ();"/> </s: hgroup> </S: titlewindow>
Main program code
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: MX = "Library: // ns.adobe.com/flex/mx" xmlns: S = "Library: // ns.adobe.com/flex/spark"> <s: layout> <s: verticallayout/> </S: layout> <FX: SCRIPT> <! [CDATA [import learning. component. loginpopupwindow; // The bullet box component has been introduced to import MX. managers. popupmanager; import spark. components. titlewindow; [Bindable]/* after binding, You can bind the attributes in loginpopupwindow with the attributes on this page */Public var loginwindow: loginpopupwindow; // the pop-up window private function showlogin (): void {// convert the iflexdisplayobject interface returned by createpopup to the loginpopupwindow type loginwindow = loginpopupwindow (popupmanager. createpopup (this, loginpopupwindow, True); loginwindow. X = 300; loginwindow. y = 200; // The main program adds the title loginwindow to the pop-up box. title = "Enter login information"; // make title bar slightly transparent. loginwindow. setstyle ("borderalpha", 0.9); // hide the close button. loginwindow. closebutton. visible = false ;}]]> </FX: SCRIPT> <s: vgroup width = "300" Height = "300"> <s: button id = "login" label = "login" Click = "showlogin ();"/> <! -- Get the value in the pop-up window --> <s: textinput text = "{loginwindow. username. Text}"/> </S: vgroup> </S: Application>