【问题标题】:AIR - set size of NativeWindow to include system chromeAIR - 设置 NativeWindow 的大小以包括系统镶边
【发布时间】:2012-02-14 07:44:09
【问题描述】:

如何找出系统chrome的大小,以便我可以指定窗口大小以达到我想要的舞台大小?

如果我的主窗口设置为 800 x 600(舞台),并且我创建如下第二个窗口,它会更小。

public function Main():void 
{
    var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
    windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
    windowOptions.type = NativeWindowType.NORMAL;
    var newWindow:NativeWindow = new NativeWindow( windowOptions );
    newWindow.width = 800;
    newWindow.height = 600;
    newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
    newWindow.stage.align = StageAlign.TOP_LEFT;
    newWindow.activate();

}

我假设您同时增加 newWindow.width = 800;newWindow.height = 600; 以说明 chrome,但是您如何找到这个值?

【问题讨论】:

    标签: actionscript-3 air stage nativewindow


    【解决方案1】:

    供参考,因为我觉得其他答案不够清楚。要将新窗口设置为所需的尺寸:

    // first set the desired window dimensions to set the (smaller) stage dimensions:
    newWindow.width = 1024;
    newWindow.height = 768;
    
    // then reset the window dimensions and add chrome dimensions:
    newWindow.width = 1024 + (1024 - newWindow.stage.stageWidth);
    newWindow.height = 768 + (768 - newWindow.stage.stageHeight);   
    

    【讨论】:

      【解决方案2】:

      使用 NO_SCALE 创建 ActionScript 项目时,stage.stageHeight 和 stage.stageWidth 不能用于计算主应用程序窗口中的镶边,因为它们不会调整大小以符合内部宽度。您必须引用主窗口阶段。

      要查找主窗口内部舞台的高度和宽度,您可以使用 stage.nativeWindow.stage 引用 stageHeight 和 stageWidth 属性来提供内部宽度。

      例如对于 1280x720 所需的内部尺寸:

      // width stage.nativeWindow.width = 1280 + (stage.nativeWindow.width -
      stage.nativeWindow.stage.stageWidth);
      
      // height stage.nativeWindow.height = 720 + (stage.nativeWindow.height
      - stage.nativeWindow.stage.stageHeight);
      

      【讨论】:

        【解决方案3】:

        您可以通过用内部尺寸(不包括镶边)减去窗口尺寸(包括镶边)来计算镶边的大小。

        来自 NativeWindows 的 width 帮助:

        为原生窗口报告的尺寸包括任何系统窗口 显示的铬。内部可用显示区域的宽度 Stage.stageWidth 属性提供了一个窗口。

        所以可以用stage object(stage.stageWidth 和stage.stageHeight:)得到内部尺寸

        因此:

        var chromeWidth=newWindow.width-newWindow.stage.stageWidth;
        var chromeHeight=newWindow.height-newWindow.stage.stageHeight;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-08-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-11-28
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多