如何在Flex中弹出窗口传递和检索值?

Kis*_*mar 5 apache-flex actionscript-3 popupwindow flex4

我想从我的自定义弹出窗口发送一些文本值,当它从主应用程序弹出一些文本输入时,我想知道如何检索用户在弹出窗口中输入的数据(文本输入).任何帮助表示赞赏.

Jar*_*nen 6

您可以使用setter访问popUp数据,如示例所示.或者在主应用程序中将popUp组件设置为全局组件,以便可以全局引用组件属性.

<!-- 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"/>
Run Code Online (Sandbox Code Playgroud)

<!-- 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>
Run Code Online (Sandbox Code Playgroud)