2009-07-03 107 views
2

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

回答

3

我想通了:

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

我认为你必须调用这个window.open()后虽然。

+0

呵呵......你已经回答了你的问题。 从我所知道的这是正确的方式来做到这一点:) – 2009-07-03 17:48:10

1

是不是更好?

例如文档:

// 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的)

0

其实这个工作更好的柔性4.5及以上

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

这就是我用的

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

似乎运作良好