【发布时间】:2009-07-03 16:47:11
【问题描述】:
我试图在 flex 中将启动的窗口居中,有一个 NativeWindow.x 和 NativeWindow.y 但 flex 使用没有这些属性的 Window 类,所以有人知道如何将窗口居中吗?谢谢!!
【问题讨论】:
标签: apache-flex air
我试图在 flex 中将启动的窗口居中,有一个 NativeWindow.x 和 NativeWindow.y 但 flex 使用没有这些属性的 Window 类,所以有人知道如何将窗口居中吗?谢谢!!
【问题讨论】:
标签: apache-flex air
我想通了:
window.nativeWindow.x = (Screen.mainScreen.bounds.width - window.width)/2;
window.nativeWindow.y = (Screen.mainScreen.bounds.height - window.height)/2;
我认为你必须在 window.open() 之后调用它。
【讨论】:
这是我用的
nativeWindow.x = (Capabilities.screenResolutionX - nativeWindow.width) / 2;
nativeWindow.y = (Capabilities.screenResolutionY - nativeWindow.height) / 2;
看起来效果不错
【讨论】:
这样不是更好吗?
示例文档:
// 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) 上,这两种解决方案都适用于我
【讨论】:
实际上这在 flex 4.5 及更高版本中效果更好
nativeWindow.x = (Screen.mainScreen.bounds.width - nativeWindow.width)/2;
nativeWindow.y = (Screen.mainScreen.bounds.height - nativeWindow.height)/2;
【讨论】: