使用弹出窗体修改数据,之后返回值
初次使用Flex,希望在程序中能使用弹出窗口的类型,就是有A、B两个窗体,B从A中弹出,并显示A中的指定数据且可修改,修改完成后的数据更新到A中:
A窗体:
<?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 _win1:win1 = new win1();
private function showWin1():void{
_win1.s_tmp = this.p_txt.text;
PopUpManager.addPopUp(_win1, this, true);
PopUpManager.centerPopUp(_win1);
_win1.addEventListener("t1", update);
}
private function update(evt:Event):void{
this.p_txt.text = _win1.s_tmp;
PopUpManager.removePopUp(_win1);
}
]]>
</mx:Script>
<mx:TextInput x="333" y="129" id="p_txt"/>
<mx:Button x="380" y="159" label="Button" click="showWin1();"/>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private var _win1:win1 = new win1();
private function showWin1():void{
_win1.s_tmp = this.p_txt.text;
PopUpManager.addPopUp(_win1, this, true);
PopUpManager.centerPopUp(_win1);
_win1.addEventListener("t1", update);
}
private function update(evt:Event):void{
this.p_txt.text = _win1.s_tmp;
PopUpManager.removePopUp(_win1);
}
]]>
</mx:Script>
<mx:TextInput x="333" y="129" id="p_txt"/>
<mx:Button x="380" y="159" label="Button" click="showWin1();"/>
</mx:Application>
B窗体:
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
[Bindable]
public var s_tmp:String;
private function click_return():void{
s_tmp = this.c_txt.text; //必须,绑定只是在此值改变的时候在Text中更新,但Text更新时绑定变量的值却不会自动改变
dispatchEvent(new Event("t1")); //手动触发事件
}
]]>
</mx:Script>
<mx:TextInput x="110" y="82" id="c_txt" text="{s_tmp}"/>
<mx:Button x="157" y="112" label="Button" click="click_return();"/>
</mx:TitleWindow>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
[Bindable]
public var s_tmp:String;
private function click_return():void{
s_tmp = this.c_txt.text; //必须,绑定只是在此值改变的时候在Text中更新,但Text更新时绑定变量的值却不会自动改变
dispatchEvent(new Event("t1")); //手动触发事件
}
]]>
</mx:Script>
<mx:TextInput x="110" y="82" id="c_txt" text="{s_tmp}"/>
<mx:Button x="157" y="112" label="Button" click="click_return();"/>
</mx:TitleWindow>