Adobe Air - Flash - 初始窗口位置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Adobe Air - Flash - 初始窗口位置相关的知识,希望对你有一定的参考价值。

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

这是一个截图:

答案

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

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

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

window.moveTo(Math.round((window.screen.availWidth - window.outerWidth) / 2), Math.round((window.screen.availHeight - window.outerHeight) / 2));
另一答案
var screenBounds:Rectangle = Screen.mainScreen.bounds;
stage.nativeWindow.x = (screenBounds.width - stage.nativeWindow.width) / 2;
stage.nativeWindow.y = (screenBounds.height - stage.nativeWindow.height) / 2;

适合我

另一答案

如果您正在使用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>

以上是关于Adobe Air - Flash - 初始窗口位置的主要内容,如果未能解决你的问题,请参考以下文章

Adobe AIR 读取 Flash Player 的 .sol 文件

Adobe Air 与 Flash Player 10.1 运行时

#error 1107使用Adobe Air在iPhone上运行Flash游戏时

Flash 10 + AS 2.0中Adobe AIR和Zinc的良好替代品

Flash Builder、Adobe AIR 和 iOS 开发的包检查失败错误

adobe air vs flex vs flash builder ---我需要解释一下