Spark TitleWindow - 将数据返回到主应用程序

发布于 2024-12-12 04:55:21 字数 443 浏览 0 评论 0原文

我创建了一个 Spark TitleWindow(使用 mxml 组件),在其中我选择了一些内容并希望它返回到主应用程序变量。 例如,在主应用程序中,我有一个变量名称 currMaxPlayers:int ,在 TitleWindows 中,我创建了一个表单,您可以选择玩家数量,当选择数量然后按提交按钮时,我希望所选的数量回到 MainApplication 中的 currMaxPlayers 变量。 我已按照此处的说明进行操作 http://help.adobe.com/en_US/flex/using/WS6c678f7b363d5da52e8f1ca1124a0430dcf-8000.html 没有成功。

谢谢

I have created a spark titlewindow (using mxml component) which there I select some stuff and want it to get back to the Main application variables.
For example, in the main application I have a var name currMaxPlayers:int and in the TitleWindows I have created a form which you can choose number of players, when selecting the number and then pressing submit button, I want the number that was selected to get back into the currMaxPlayers var in the MainApplication.
I have followed the instructions here http://help.adobe.com/en_US/flex/using/WS6c678f7b363d5da52e8f1ca1124a0430dcf-8000.html with no success.

Thanks

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

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

发布评论

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

评论(1

秋风の叶未落 2024-12-19 04:55:21

假设您使用 PopUpManager 打开自定义 TitleWindow,PopUpManager 应调度一个带有玩家数量值的自定义事件,并且打开 TitleWindow 的组件可以侦听该事件。在不编写正式测试的情况下,编写如下代码:

// In The component that creates the TitleWindow:
var newTitleWindow : MyTitleWindow = new MyTitleWindow();
newTitleWindow.addEventListener('numberOfPlayersChanged', onNumberofPlayersChanged); 
PopUpManager.addPopUp(newTitleWindow , this );

您的自定义事件类:

package events
{
    import flash.events.Event;

    public class MyEvent extends Event
    {
        public var numberOfPlayers:int;

        public function MyEvent (type:String, bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
        }
    }
}

在标题窗口中,分派该事件:

var newEvent : MyEvent = new MyEvent('numberOfPlayersChanged')
newEvent.numberOfPlayers = // whatever procedure you use to get the number of players
dispatchEvent(newEvent);

并返回到创建标题窗口的模板:

protected function onNumberofPlayersChanged(event:MyEvent):void{
  trace(event.numberOfPlayers);
  // do something else with number of players
}

Assuming that you are opening your custom TitleWindow with the PopUpManager, the PopUpManager should dispatch a custom event with the number of players value and the component which opens the TitleWindow can listen for that event. Without writing formal tested, code something like this:

// In The component that creates the TitleWindow:
var newTitleWindow : MyTitleWindow = new MyTitleWindow();
newTitleWindow.addEventListener('numberOfPlayersChanged', onNumberofPlayersChanged); 
PopUpManager.addPopUp(newTitleWindow , this );

Your custom event class:

package events
{
    import flash.events.Event;

    public class MyEvent extends Event
    {
        public var numberOfPlayers:int;

        public function MyEvent (type:String, bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
        }
    }
}

In the Title Window, dispatch that event:

var newEvent : MyEvent = new MyEvent('numberOfPlayersChanged')
newEvent.numberOfPlayers = // whatever procedure you use to get the number of players
dispatchEvent(newEvent);

And back to the template which creates the title window:

protected function onNumberofPlayersChanged(event:MyEvent):void{
  trace(event.numberOfPlayers);
  // do something else with number of players
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文