You just need to center AIR window on screen both vertically and horizontally. How do I center my AIR window?
Use screen resolution and native window size properties to set desired coordinates.
Set AIR window x coordinate using Capabilities.screenResolutionX and nativeWindow.width. Do the same for y coordinate with Capabilities.screenResolutionY and nativeWindow.height. Use the simple formula:
// Align native AIR application window horizontally and vertically nativeWindow.x = (Capabilities.screenResolutionX - nativeWindow.width) / 2; nativeWindow.y = (Capabilities.screenResolutionY - nativeWindow.height) / 2;
The code is simple, but I hope it will save time to someone. To quick test it in Flex, paste the code below in new MXML application:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
width="450" height="400" layout="absolute"
creationComplete="creationCompleteHandler(event);">
<mx:Script>
<![CDATA[
private function creationCompleteHandler(event: Event): void
{
nativeWindow.x = (Capabilities.screenResolutionX - nativeWindow.width) / 2;
nativeWindow.y = (Capabilities.screenResolutionY - nativeWindow.height) / 2;
}
]]>
</mx:Script>
</mx:WindowedApplication>
+