`

flex弹出窗体的应用 PopUpManager类

阅读更多
一,Flex的主程序 PopUpDemo.mxml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;

private var tw:titlewindow=new titlewindow();
private function mytw_click():void{
  tw.owner = this;
PopUpManager.addPopUp(tw,this);
  PopUpManager.centerPopUp(tw);
}
]]>
</mx:Script>
<mx:Panel x="94" y="178" width="503" height="347" layout="absolute">
<mx:TextInput x="134" y="64" id="tit_usr" text="username"/>
    <mx:TextInput x="134" y="125" id="tit_psw" text="password"/>
    <mx:Button x="171" y="209" label="Submit" click="mytw_click()"/>
</mx:Panel>
</mx:Application>

二,点击主程序button弹出窗体  titlewindow.mxml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="498" height="368" showCloseButton="true" close="PopUpManager.removePopUp
(this)">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;

private function btn_click():void{
          dispatchEvent(new Event("tw_click"));
var a:PopUpDemo = this.owner as PopUpDemo;
  a.tit_usr.text = this.tw_usr.text;
  a.tit_psw.text = this.tw_psw.text;
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:Label x="96" y="67" text="用户名" width="97" height="26"/>
<mx:Label x="96" y="128" text="密码" width="97" height="24"/>
<mx:TextInput x="217" y="65" id="tw_usr"/>
<mx:TextInput x="217" y="126" id="tw_psw"/>
<mx:Button x="228" y="239" label="Click" click="btn_click()"/>
</mx:TitleWindow>

代码解释:点击主程序的button 弹出窗体TitleWindow,在弹出的窗体中输入username和password,点击Click,弹出窗体TitleWindow关闭,主程序上显示弹出窗体输入的username和password。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics