flex TitleWindow之间数据传输的示例
2011-10-09 17:04
459 查看
在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,titleWin,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>
假设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,titleWin,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>
相关文章推荐
- FLEX TitleWindow之间数据传输的示例
- flex TitleWindow之间数据传输的示例
- FLEX TitleWindow之间数据传输的示例
- FLEX TitleWindow之间数据传输的示例
- flex titlewindow与module之间数据通信
- flex 自定义组件(TitleWindow)与组件(TitleWindow)之间交互传值
- Activity之间的数据传输的示例(实现根据身高计算标准体重)
- Flex 和C++ 之间传输结构体数据--用XML传输
- 驱动程序学习(三)示例2 :设备驱动程序与应用程序之间数据传输的另外一种方式
- flex外部自定义组件TitleWindow对话框与主程序之间的通信
- android学习:两个Activity之间的数据传输
- Java NIO系列教程(五) 通道之间的数据传输
- Java NIO系列教程(五) 通道之间的数据传输
- 【转】Flex与.NET互操作(四):使用HttpService、URLReqeust和URLLoader加载/传输数据
- window.name实现的跨域数据传输
- Flex4 Spark组件数据驱动简单示例
- 五 通道之间的数据传输
- Hadoop平台上用Sqoop在Hive和DB2数据库之间传输数据的实践和总结
- flex titlewindow 拖动 父窗口范围
- Windows XP SP3环境下的OLE DB Remoting Provider和Jet Provider之间是如何进行数据传输的