views:

452

answers:

2
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init1()" width="100%">
<mx:Script>
     <![CDATA[
         import mx.controls.Alert;
      public function init1():void
      {
          Alert.show(this.width.toString());
      }
     ]]>
    </mx:Script>
</mx:WindowedApplication>

I am running the above code on a monitor with resolution 800x600. So, I expect that the Alert that pops out will show the width to be 800. But it shows the width to be 500. Why?

A: 

The property width="100%" won't do anything as it is an AIR application and it's default state is not always maximized (at least on my Mac OS). The snippet below automatically maximize the app and trace its bounds and current state whenever you minimize, maximize or restore the window.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication  
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute"
    creationComplete="maximize()"
    displayStateChange="onDisplayStateChange(event)">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            public function onDisplayStateChange(event:NativeWindowDisplayStateEvent):void {
         Alert.show(event.afterDisplayState + ' ' + bounds.toString());
            }
        ]]>
    </mx:Script>
</mx:WindowedApplication>
julotlafrite
A: 

You can also use Capabilities.screenResolutionX and capabilities.screenResolutionY to find out screen size.

Hrundik