【问题标题】:Flex: center Window?Flex:中心窗口?
【发布时间】:2009-07-03 16:47:11
【问题描述】:

我试图在 flex 中将启动的窗口居中,有一个 NativeWindow.x 和 NativeWindow.y 但 flex 使用没有这些属性的 Window 类,所以有人知道如何将窗口居中吗?谢谢!!

【问题讨论】:

    标签: apache-flex air


    【解决方案1】:

    我想通了:

    window.nativeWindow.x = (Screen.mainScreen.bounds.width - window.width)/2;
    window.nativeWindow.y = (Screen.mainScreen.bounds.height - window.height)/2;
    

    我认为你必须在 window.open() 之后调用它。

    【讨论】:

    • 呵呵...你已经回答了你的问题。据我所知......这是正确的做法:)
    【解决方案2】:

    这是我用的

    nativeWindow.x = (Capabilities.screenResolutionX - nativeWindow.width) / 2; nativeWindow.y = (Capabilities.screenResolutionY - nativeWindow.height) / 2;

    看起来效果不错

    【讨论】:

      【解决方案3】:

      这样不是更好吗?

      示例文档:

      // center the window on the screen
      var screenBounds:Rectangle = Screen.mainScreen.bounds;
      nativeWindow.x = (screenBounds.width - nativeWindow.width) / 2;
      nativeWindow.y = (screenBounds.height - nativeWindow.height) / 2;
      

      from livedocs: about window containers ¨

      即使在多屏系统 (Win7) 上,这两种解决方案都适用于我

      【讨论】:

        【解决方案4】:

        实际上这在 flex 4.5 及更高版本中效果更好

        nativeWindow.x = (Screen.mainScreen.bounds.width - nativeWindow.width)/2;
        nativeWindow.y = (Screen.mainScreen.bounds.height - nativeWindow.height)/2;
        

        【讨论】:

          猜你喜欢
          • 2012-02-10
          • 2012-10-29
          • 1970-01-01
          • 1970-01-01
          • 2012-01-18
          • 2012-09-10
          • 2014-08-30
          • 2019-09-16
          • 1970-01-01
          相关资源
          最近更新 更多