如何在 Flex 中向弹出窗口传递值或从弹出窗口检索值?

发布于 2024-11-28 13:09:51 字数 88 浏览 1 评论 0原文

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

I want to send some text value to my custom popup window when it pops up from main application which is having some text input and also I want to know how to retrieve data(of text input) which entered by a user in popup window. Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-12-05 13:09:51

您可以使用 setter 访问 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>

You can access popUp data using setter as example shows. Or make a popUp component as a global in your main application so you can refer component properties globally.

<!-- 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>
桃扇骨 2024-12-05 13:09:51
var popup:YourPopupWindow = PopupManager.createPopup(YourPopupWindow, true) as YourPopupWindow;
popup.someData = yourData;
var popup:YourPopupWindow = PopupManager.createPopup(YourPopupWindow, true) as YourPopupWindow;
popup.someData = yourData;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文