Adobe Air - Flash - 初始窗口位置

问题描述 投票:3回答:4

我正在设计一个使用Adobe Flash CS6的桌面应用程序,使用air 3.2 for desktop(在flash目标设置中)。在空中设置中,有一个高级选项卡,可以设置应用程序窗口位置的初始值。我不知道应该如何将它设置到屏幕中间。

这是一个截图:

flash air window-position
4个回答
5
投票

不要使用这些属性,只需向您的应用添加代码:

stage.nativeWindow.x = (Capabilities.screenResolutionX - this.width)*0.5;
stage.nativeWindow.y = (Capabilities.screenResolutionY - this.height)*0.5;

0
投票

对于基于HTML / JS的AIR项目,您可以使用:

window.moveTo(Math.round((window.screen.availWidth - window.outerWidth) / 2), Math.round((window.screen.availHeight - window.outerHeight) / 2));

0
投票
var screenBounds:Rectangle = Screen.mainScreen.bounds;
stage.nativeWindow.x = (screenBounds.width - stage.nativeWindow.width) / 2;
stage.nativeWindow.y = (screenBounds.height - stage.nativeWindow.height) / 2;

适合我


0
投票

如果您正在使用FlashBuilder或用于WindowedApplication的MXML文件,则可以在初始化处理程序中以这种方式执行此操作。这使用从nativeWindow的边界读取的应用程序的初始维度(在application.xml文件中定义)。 [MXML文件内容]

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       xmlns:local="*"                     
                       initialize="windowedapplication1_initializeHandler(event)"
                       >
<fx:Script>
        <![CDATA[
            protected function windowedapplication1_initializeHandler(event:FlexEvent):void
            {
                var w:int = Capabilities.screenResolutionX;
                var h:int = Capabilities.screenResolutionY;
                nativeWindow.x = (w - nativeWindow.bounds.width)*0.5;
                nativeWindow.y = (h - nativeWindow.bounds.height)*0.5;
            }

]]>
</fx:Script>
</s:WindowedApplication>
© www.soinside.com 2019 - 2024. All rights reserved.