Center an Adobe AIR application on Screen
21 June 2009
2 Comments
By default NativeWindow loads some where on the screen. Loading an splash screen or application on center of the screen will gives better user experience.

Below code we are creating a native window and aligning in the screen center.
var _splashWindow:NativeWindow = new NativeWindow(nativeWindowOptions); _splashWindow.width = 484; _splashWindow.height = 289; _splashWindow.stage.align = "TL"; _splashWindow.stage.scaleMode = "noScale"; _splashWindow.title = "Center on screen"; var screenBounds:Rectangle = Screen.mainScreen.bounds; _splashWindow.x = (screenBounds.width - _splashWindow.width)/2; _splashWindow.y = (screenBounds.height - _splashWindow.height)/2; _splashWindow.activate();
Here,
var screenBounds:Rectangle = Screen.mainScreen.bounds;
Screen.mainScreen.bounds return the screen boundary.
_splashWindow.x = (screenBounds.width - _splashWindow.width)/2; _splashWindow.y = (screenBounds.height - _splashWindow.height)/2;
Centering the application on screen.
Translate this post











































Leave your response!