从不同 mxml 组件中的 TitleWindow 调用 Application.application.enable [英] Calling Application.application.enable from a TitleWindow in a different mxml component
问题描述
我有一个 Flex RIA 应用程序,在应用程序标签中有一个按钮,当按下它时会调用另一个 .mxml 文件中的 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
这样用户就不能使用应用程序中的任何组件,仍然可以使用 TitleWindow 中的组件.
That way the user can't use any of the components in the application, and still can use the components in the TitleWindow.
问题是当 TitleWindow 关闭时我想让它把应用程序恢复到
The problem is when the TitleWindow is closed I want it to restore the application back to
application.enable = true
再次启用应用程序.但我无法从 TitleWindow .mxml 内部调用该代码
Which enables the application once again. But I can't call that code from inside the 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>
还有一个标题窗口.一旦它们相同.
And one of the title windows. Once they are the same.
登录.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>
推荐答案
application
是 Application
类的静态属性,可以从 TitleWindow 调用
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:
这样用户就不能使用应用程序中的任何组件,仍然可以使用 TitleWindow 中的组件.
That way the user cant use any of the components in the application, and still can use the components in the TitleWindow.
即使用模态弹窗.将 createPopUp
的第三个参数设置为 true
就是这样 - 您不必手动启用/禁用应用程序:flex 会处理它.
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);
应用程序将在您调用 removePopUp
后自动生效.
application will automatically become functional once you call removePopUp
.
这篇关于从不同 mxml 组件中的 TitleWindow 调用 Application.application.enable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!