从不同 mxml 组件中的 TitleWindow 调用 Application.application.enable

发布于 2024-08-05 04:53:59 字数 2294 浏览 2 评论 0原文

我有一个 Flex RIA 应用程序,在应用程序标签中有一个按钮,按下时会调用另一个 .mxml 文件中的 TitleWindow,并设置

application.enable = false

这样用户就无法使用应用程序中的任何组件,但仍然可以使用 TitleWindow 中的组件。

问题是,当 TitleWindow 关闭时,我希望它将应用程序恢复到

application.enable = true

再次启用应用程序的状态。但我无法从 TitleWindow .mxml 内部调用该代码,

我该怎么做?

这是源代码:

Loja.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="585" height="450" xmlns:ns1="com.*">
<mx:Style source="theme/simplicitygray.css" />

    <mx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            private var clientid = 0;       
            
            public function openWindow() : void
            {
                if (clientid == 0) 
                {
                    PopUpManager.createPopUp(this,Login,false);
                    application.enabled = false;
                } else {
                    PopUpManager.createPopUp(this,Conta,false);
                    application.enabled = false;
                }
            }
        ]]>
    </mx:Script>
    
    <mx:Panel x="10" y="40" width="565" height="400" layout="absolute">
    </mx:Panel>
    <mx:MenuBar x="10" y="10" width="565" height="22"></mx:MenuBar>
    <mx:Button x="508" y="10" label="Aceder" click="openWindow();"/>
    
</mx:Application>

以及标题窗口之一。一旦它们是相同的。

登录.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="350" height="200" creationComplete="centerWindow()" showCloseButton="true" close="closeWindow()" title="Login">
    
    <mx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function centerWindow():void
            {
                PopUpManager.centerPopUp(this);
            }
            
            public function closeWindow():void
            {
                PopUpManager.removePopUp(this);
            
            }
            
       ]]>
       
    </mx:Script>
    
</mx:TitleWindow>

I have a Flex RIA App, and in the application tag there is a button when it's pressed calls upon a TitleWindow from another .mxml file, and sets

application.enable = false

That way the user can't use any of the components in the application, and still can use the components in the TitleWindow.

The problem is when the TitleWindow is closed I want it to restore the application back to

application.enable = true

Which enables the application once again. But I can't call that code from inside the TitleWindow .mxml

How can I do it?

Here is the Source:

Loja.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="585" height="450" xmlns:ns1="com.*">
<mx:Style source="theme/simplicitygray.css" />

    <mx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            private var clientid = 0;       
            
            public function openWindow() : void
            {
                if (clientid == 0) 
                {
                    PopUpManager.createPopUp(this,Login,false);
                    application.enabled = false;
                } else {
                    PopUpManager.createPopUp(this,Conta,false);
                    application.enabled = false;
                }
            }
        ]]>
    </mx:Script>
    
    <mx:Panel x="10" y="40" width="565" height="400" layout="absolute">
    </mx:Panel>
    <mx:MenuBar x="10" y="10" width="565" height="22"></mx:MenuBar>
    <mx:Button x="508" y="10" label="Aceder" click="openWindow();"/>
    
</mx:Application>

And one of the title windows. Once they are the same.

Login.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="350" height="200" creationComplete="centerWindow()" showCloseButton="true" close="closeWindow()" title="Login">
    
    <mx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            public function centerWindow():void
            {
                PopUpManager.centerPopUp(this);
            }
            
            public function closeWindow():void
            {
                PopUpManager.removePopUp(this);
            
            }
            
       ]]>
       
    </mx:Script>
    
</mx:TitleWindow>

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

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

发布评论

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

评论(2

怀里藏娇 2024-08-12 04:53:59

applicationApplication 类的静态属性,可以从 TitleWindow 调用

public function closeWindow():void
{
    PopUpManager.removePopUp(this);
    Application.application.enabled = true;
}

BTW,还有另一种更简单的方法来实现以下目的:

这样用户就无法使用应用程序中的任何组件,但仍然可以使用 TitleWindow 中的组件。

那就是使用模态弹出窗口。将 createPopUp 的第三个参数设置为 true 就这样 - 您不必手动启用/禁用应用程序:flex 会处理它。

PopUpManager.createPopUp(this,Login, true);

一旦您调用removePopUp,应用程序将自动开始运行。

application is a static property of the Application class and can be called from the TitleWindow

public function closeWindow():void
{
    PopUpManager.removePopUp(this);
    Application.application.enabled = true;
}

BTW, There is another easier way to achieve the following:

That way the user cant use any of the components in the application, and still can use the components in the TitleWindow.

That is to use a modal popup. Set the third parameter of the createPopUp to true and that's it - you don't have to enable/disable the application manually: flex will take care of it.

PopUpManager.createPopUp(this,Login, true);

application will automatically become functional once you call removePopUp.

很酷又爱笑 2024-08-12 04:53:59

您可以使用自定义事件来启用此功能,如所述

本质上,您在调用的类中设置一个自定义事件,然后创建一个在事件被消耗时运行的函数。这样您的“Loja”就会知道“登录”何时完成。

You can use custom events to enable this functionality, as described here.

Essentially, you set up a custom event in the class you are calling, then create a function that runs when the event is consumed. That way your 'Loja' will know when the 'Login' is done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文