Reply to comment

Setting AIR window size whilst ignoring chrome

You specify the size of the initial window of your AIR application within an application descriptor file, like below:

<?xml version="1.0"?>
<application xmlns="http://ns.adobe.com/air/application/1.0">
    :
    :
    <initialWindow>
	<title>MyWindow</title>
        <content>main.swf</content>
        <width>800</width>
        <height>600</height>
    </initialWindow>
    :
</application>

However, the width and height you give here won't be the width and height of the stage you end up with, because your AIR window includes chrome - i.e. the window borders, titlebar, buttons etc. The size you actually get for your stage, given the application descriptor above, would be 800 - (2 x window border) by 600 - (2 x window border + title bar). Or slightly smaller than you might want, and slightly out of proportion.

The following quick hack gets around it. The idea is that, within your AIR app, you read the required width and height from your app descriptor file and adjust the stage size to fit; your app's window will inflate accordingly.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
    xmlns:mx="http://www.adobe.com/2006/mxml"
    windowComplete="onWindowComplete()">
    <mx:Script><![CDATA[
 
    private function onWindowComplete():void
    {
        /** This function grabs the desired app size from the application descriptor
        * file, and sets the stage size to that - because the standard AIR size includes
        * chrome.
        */
        var appDescriptor:XML = XML(nativeApplication.applicationDescriptor);
        var ns:Namespace = xml.namespace();
 
        var appWidth:int=parseInt(appDescriptor.ns::initialWindow.ns::width);
        var appHeight:int = parseInt(appDescriptor.ns::initialWindow.ns::height);
 
        stage.stageWidth = appWidth;
        stage.stageHeight = appHeight;
    }
 
    ]]></mx:Script>
    <!-- Application contents goes here -->
</mx:WindowedApplication>

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <i> <b> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode> <h1> <h2> <h3> <h4> <h5> <h6>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.