Multi-monitor Support in AIR

I’ve seen several people ask about multi-monitor support in AIR. The answer is: it’s there, and it’s very good.

Take a look at the flash.display.Screen class (AIR only — not available in the Flash Player). It contains the following properties:

  • bounds
  • colorDepth
  • mainScreen (for getting a Screen reference to the main screen when there are multiple monitors)
  • screens (an array of Screen objects for all attached monitors)
  • visibleBounds (returns a Rectangle that excludes unusable portions of the screen like the taskbar, menu bar, and the dock)

The Screen class also contains a very cool function called getScreensForRectangle that returns an array of screens that intersect the specified Rectangle.

We’ve also added a ScreenMouseEvent that is dispatched by SystemTrayIcon and gives you the coordinates of a click relative to the main screen as opposed to an application window.

For a relatively simple example of the Screen APIs in action, check out SPF on the Adobe Labs Sample Application page.

5 Responses to Multi-monitor Support in AIR

  1. Mark Mazelin says:

    Christian:There is no sample app called “SPF” or any verbiage relating to multiple monitors on the labs link you provided. Help?Mark

  2. Christian Cantrell says:

    The code is now available on Google Code here:http://code.google.com/p/screenprotectionfactor/Christian

  3. arpit says:

    Any reason this isn’t part of the Flash Player? Is there any possibility this will be part of Flash Player 10 ?

  4. Christian Cantrell says:

    It’s always possible that AIR APIs could find their way into the Flash Player, but I doubt the Screen APIs will be integrated anytime soon. They won’t do much good since you can’t do thinks like open new windows.Christian

  5. I’ve looked in to this a while ago and build a ScreenManager to move and activate screens on one of the screens.Take a look at this;http://www.joristimmerman.be/wordpress/2009/03/03/screenmanager-expand-your-air-application/