Home » AIR, ActionScript 3.0

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.

VN:F [1.7.7_1013]
Rating: 0.0/10 (0 votes cast)
VN:F [1.7.7_1013]
Rating: 0 (from 0 votes)
Translate this post
        
        
        
        
  

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.