在我的application.xml中,我可以设置初始窗口的位置。但是,这是从屏幕左上角设置的像素。
那我该如何居中呢?
答案 0 :(得分:1)
将其放入应用程序的creationComplete
事件处理程序
var screenBounds:Rectangle = Screen.mainScreen.bounds;
nativeWindow.x = (screenBounds.width - nativeWindow.width) / 2;
nativeWindow.y = (screenBounds.height - nativeWindow.height) / 2;
答案 1 :(得分:1)
试试这个(这是JavaScript):
var bounds = null;
var screen = air.Screen.mainScreen.visibleBounds;
bounds = new air.Rectangle(
(screen.width - WINDOW_WIDTH ) / 2,
(screen.height - WINDOW_HEIGHT) / 2,
WINDOW_WIDTH,
WINDOW_HEIGHT
);
htmlLoader.stage.nativeWindow.bounds = bounds;