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

前端之家收集整理的这篇文章主要介绍了如何在Flex中弹出窗口传递和检索值?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想从我的自定义弹出窗口发送一些文本值,当它从主应用程序弹出一些文本输入时,我想知道如何检索用户在弹出窗口中输入的数据(文本输入).任何帮助表示赞赏.

解决方法

您可以使用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"/>
<!-- 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>

猜你在找的Flex相关文章