是否可以防止 Flex 应用程序在运行时调整大小?

发布于 2024-09-19 02:37:31 字数 561 浏览 3 评论 0原文

据我所知,Flex 应用程序的调整大小属性是在 XML 配置文件中设置的:

<!--Whether the user can resize the window. Optional. Default true.-->
<!--<resizable></resizable>-->

但是,如果我将此属性设置为 true,是否有办法在运行时动态关闭此属性?例如,我的应用程序有两种视图模式 - 迷你和最大。我想阻止最终用户在迷你模式下调整应用程序的大小。我尝试使用以下代码阻止调整大小,但它似乎不起作用:

private function creationComplete():void {
    this.systemManager.stage.addEventListener(Event.RESIZE, resizeListener);
}

private function resizeListener(evt:Event):void {
    evt.preventDefault();
}

任何帮助将不胜感激。

From what I can gather, the resize property of a Flex application is set in the XML config file:

<!--Whether the user can resize the window. Optional. Default true.-->
<!--<resizable></resizable>-->

However, if I set this attribute to true, is there a way to turn this off dynamically at runtime? For example, my application has two view modes - mini and maxi. I would like to prevent the end user from being able to resize the application when in mini mode. I tried prevent the resize using the following code but it does not seem to work:

private function creationComplete():void {
    this.systemManager.stage.addEventListener(Event.RESIZE, resizeListener);
}

private function resizeListener(evt:Event):void {
    evt.preventDefault();
}

Any help would be greatly appreciated.

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

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

发布评论

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

评论(5

棒棒糖 2024-09-26 02:37:31

还有另一种方法可以在不设置描述符文件属性的情况下执行此操作。

这是代码:

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" showGripper="false"
                    layout="vertical" showStatusBar="false"
                    applicationComplete="init()">

<mx:Script>
    <![CDATA[
        import mx.events.FlexNativeWindowBoundsEvent;

        private function init():void
        {
            this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
            nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, onAppResize);
        }

        private function onAppResize(e:NativeWindowBoundsEvent):void
        {
                e.preventDefault();
        }

   ]]>
</mx:Script>

希望这有帮助。

There is another way to do that without setting the descriptor file property.

Here is the code:

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" showGripper="false"
                    layout="vertical" showStatusBar="false"
                    applicationComplete="init()">

<mx:Script>
    <![CDATA[
        import mx.events.FlexNativeWindowBoundsEvent;

        private function init():void
        {
            this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
            nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, onAppResize);
        }

        private function onAppResize(e:NativeWindowBoundsEvent):void
        {
                e.preventDefault();
        }

   ]]>
</mx:Script>

Hope this helps.

つ低調成傷 2024-09-26 02:37:31

您需要创建一个新的 NativeWindow 实例并将您的应用程序重新设置为该实例。当您创建新的 NativeWindow 时,您可以在初始化时设置选项,包括调整大小。
http://help.adobe.com /en_US/FlashPlatform//reference/actionscript/3/flash/display/NativeWindowInitOptions.html

You'd need to create a new NativeWindow instance and reparent your application into that. When you create a new NativeWindow, you've got options you can set at Initialisation time, including resizable.
http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/display/NativeWindowInitOptions.html

清泪尽 2024-09-26 02:37:31

根据手册ressized 是只读属性。
所以这可能是不可能的。

According to manual, resizable is read-only property.
So it's probably not possible.

我喜欢麦丽素 2024-09-26 02:37:31

因为这已经死了,我很好奇:

我能够使用以下代码实现从可调整大小到不可调整大小的切换:

private var maxMode:Boolean = true;

protected function switchMode():void
{
    if (maxMode){
        //I chose to freeze the app at current size
        //You could also set the min/max to hard coded values
        this.maxWidth = this.width;
        this.minWidth = this.width;
        this.maxHeight = this.height;
        this.minHeight = this.height;
    }
    else {
        //default values for WindowedApplication
        this.maxWidth = 2880;
        this.minWidth = 0;
        this.maxHeight = 2880;
        this.minHeight = 0;
    }

    maxMode= !maxMode
}

但是,用户仍然会在应用程序的边缘显示调整大小的鼠标图标。

As this was already necro'd, and I was curious:

I was able to implement a switch from resizable to not with the following code:

private var maxMode:Boolean = true;

protected function switchMode():void
{
    if (maxMode){
        //I chose to freeze the app at current size
        //You could also set the min/max to hard coded values
        this.maxWidth = this.width;
        this.minWidth = this.width;
        this.maxHeight = this.height;
        this.minHeight = this.height;
    }
    else {
        //default values for WindowedApplication
        this.maxWidth = 2880;
        this.minWidth = 0;
        this.maxHeight = 2880;
        this.minHeight = 0;
    }

    maxMode= !maxMode
}

The user is however still shown the resize mouse icons on the edges of the app.

说不完的你爱 2024-09-26 02:37:31

尝试添加返回:

evt.preventDefault();
return;

Try to add return:

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