The following example shows how you can detect the number of screens on a user’s system in Adobe AIR by using the static, read-only Screen.screens property.

From the documentation:

  • colorDepth - The color depth of this screen (expressed in number of bits).
  • visibleBounds - The visibleBounds of a screen excludes the task bar (and other docked desk bars) on Windows, and excludes the menu bar and, depending on system settings, the dock on Mac OS X.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2010/03/15/detecting-the-number-of-screens-on-a-users-system-in-adobe-air/ -->
<mx:WindowedApplication name="Screen_screens_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();">
 
    <mx:Script>
        <![CDATA[
            private function init():void {
                var tmp:Screen;
                txt.htmlText = "<b>You have " + Screen.screens.length + " screens:</b>\n";
                for each (tmp in Screen.screens) {
                    txt.htmlText += "<li>width:" + tmp.visibleBounds.width + ", height:" + tmp.visibleBounds.height + ", colorDepth:" + tmp.colorDepth + "</li>";
                }
            }
        ]]>
    </mx:Script>
 
    <mx:Text id="txt" width="300" />
 
</mx:WindowedApplication>
Tagged with:
 

2 Responses to Detecting the number of screens on a users system in Adobe AIR

  1. Roy A Koch says:

    How do I know if adobe is installed and working properly?

    • Machiel Heinen says:

      sorry, but there is no way from flash/air to check if flash/air is correctly installed. Basicly, make a “hello world” app and run it to test or download a tested and working app from the adobe download section to test it out.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree