[英]How to pass and retrieve values to/from popup window in Flex?
我想向我的自定義彈出窗口 window 發送一些文本值,當它從具有一些文本輸入的主應用程序彈出時,我還想知道如何檢索用戶在彈出窗口 window 中輸入的數據(文本輸入)。 任何幫助表示贊賞。
如示例所示,您可以使用 setter 訪問彈出數據。 或者在您的主應用程序中將彈出組件作為全局組件,以便您可以全局引用組件屬性。
<!-- TitleWindow.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="600" title="" height="160">
<fx:Script>
<![CDATA[
public function get UserTypedData():String
{
return tiSomeText.text;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:TextInput id="tiSomeText" x="76" y="101"/>
<!-- Application.mxml -->
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="100%" >
<fx:Script>
<![CDATA[
public var popup:YourPopupWindow;
private function createPopUp():void
{
popup = YourPopupWindow(PopUpManager.createPopUp(this, YourPopupWindow, false));
}
private function getPopUpData():String
{
var retVal:String = "";
if (popUp != null)
{
// get data from setter
retVal = popUp.UserTypedData();
// of from TextInput
retVal = popUp.tiSomeText.text;
}
return retVal;
}
]]>
</fx:Script>
</mx:Application>
var popup:YourPopupWindow = PopupManager.createPopup(YourPopupWindow, true) as YourPopupWindow;
popup.someData = yourData;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.