加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex TitleWindow之间数据传输的示例

发布时间:2020-12-15 01:12:15 所属栏目:百科 来源:网络整理
导读:在Flex里,一般的弹出窗口(除了Alert以外)都可以用TitleWindow组件完成,主窗口和TitleWindow的数据传输可以用以下方法: 假设TitleWindow的实例文件为titleWin.mxml,则要在Application中用PopUpManager创建一个titleWin的引用 private var popWin:titleW

在Flex里,一般的弹出窗口(除了Alert以外)都可以用TitleWindow组件完成,主窗口和TitleWindow的数据传输可以用以下方法: 假设TitleWindow的实例文件为titleWin.mxml,则要在Application中用PopUpManager创建一个titleWin的引用 private var popWin:titleWin = titleWin(PopUpManager.createPopUp(this,titleWin,true)); 如果要将Application的一个组件的值传给titleWin,如Application的id="userName"的TextInput的值传给titleWin,必须先在titleWin.mxml里声明一个TextInput的组件: public var userNameInPop:TextInput; 然后在Application里: popWin.userNameInPop=userName; 这样就相当于把Application的userName的TextInput组件传给了titleWin,可以在titleWin.mxml里绑定这个值然后在文本框里显示出来: [Bindable] public var userNameInPop:TextInput; <mx:TextInput x="110" y="39" id="popUserName" text="{userNameInPop.text}"/> 而要把titleWin的值传给Application则只需在titleWin.mxml里把TextInput的值赋给userNameInPop的text即可: userNameInPop.text=popUserName.text; 全部代码如下: titleWin.mxml <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" showCloseButton="true" close="PopUpManager.removePopUp(this)"> ??? <mx:Script> ??????? <![CDATA[ ??????????? import mx.managers.PopUpManager; ??????????? //[Bindable] ??????????? //public var userName:TextInput; ??????????? [Bindable] ??????????? public var userNameInPop:TextInput; ??????????? [Bindable] ??????????? public var userEmailInPop:TextInput; ??????????? private function showText():void ??????????? { ??????????????? userNameInPop.text=popUserName.text; ??????????????? userEmailInPop.text=popEmail.text; ??????????????? PopUpManager.removePopUp(this); ??????????? } ??????? ]]> ??? </mx:Script> ??? <mx:Label text="用户名:" x="57" y="41"/><mx:TextInput x="110" y="39" id="popUserName" text="{userNameInPop.text}"/> ??? <mx:Label text="邮箱:" x="57" y="71"/><mx:TextInput x="110" y="69" id="popEmail" text="{userEmailInPop.text}"/> ??? <mx:Button x="157" y="99" label="Button" click="showText()"/> ?? </mx:TitleWindow> mainWindow.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 function pop():void ??????????? { ??????????????? var popWin:titleWin = titleWin(PopUpManager.createPopUp(this,true)); ??????????????? popWin.title="弹出窗口"; ??????????????? popWin.userNameInPop=userName; ??????????????? popWin.userEmailInPop=email; ??????????? } ??????? ]]> ??? </mx:Script> ??? <mx:Label text="用户名:" x="106" y="95"/><mx:TextInput x="159" y="91" id="userName" text="ssz413"/> ??? <mx:Label text="邮箱:" x="106" y="144"/><mx:TextInput x="159" y="142" id="email" text="ssz425"/> ??? <mx:Button x="207" y="189" label="Button" click="pop()"/> ?? </mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读