2009-07-03 88 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;

似乎運作良好