How to Debug Fullscreen AIR Apps on a Secondary Display

Like many developers, I have a dual monitor setup. I also have certain monitors that over time have become the "Home Display" for certain programs. I almost always write code on the left-hand display (my OS primary). Firefox and applications I am developing are virtually always on the right-hand display.

So I've been developing a full screen AIR app lately and have been irritated that the AIR application always wants to open on my primary display, thus covering my IDE and also covering any debug controls in Flex Builder. For awhile I moved Flex Builder over to the right-hand screen, but that just felt wrong, so today I figured out how to programmatically move the AIR app to the secondary display.

Turns out it just took one line of code (line 10 below), setting the stage's x coordinates to the righthand boundary of my primary display (which is also the left-boundary of my right-hand display). Now this might be old hat for Flash developers, but not for me. I thought I'd post a little mini-app example of making this work.

Note that your milage with this example may vary if you:

  1. Only have one display (it will move the AIR app out of your visible area)
  2. Your displays are setup to be above each other rather than beside each other (same result as 1)
  3. Your primary OS display is on the right (same again)

If you are looking to do something different with multiple displays, check out the Livedocs page for Enumerating the screens and the ASDoc for the Screen class.

UPDATE (10:20am)

Okay, so I thought better of my solution. This code does the same thing, but just moves the AIR app to the rightmost display. If there is only one display it will just stay there.

Comments (2)

Add Comment ]

Graeme Wicksted I found that if you place the full screen line under the one that positions the stage, it will properly size the window for the secondary display (important if you are running different resolutions).

I have also changed the starting index to 0 in the Screen.screens for loop. This will allow the application to locate the right-hand monitor if it is your primary monitor according to your system.

for (var i:int=0; i < Screen.screens.length; i++) {
if (Screen.screens[i].bounds.left > stage.nativeWindow.x) {
stage.nativeWindow.x = Screen.screens[i].bounds.left;
}
}
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
Fletch Thanks a lot for this info - very helpful! Like the first comment I also had to put the resizing bit at the end to cope with the different resolutions. Actually I'm using stage.nativeWindow.maximize(); instead which I prefer.

I guess you have to do something though to avoid this code being used in a production build? Because I guess when it's installed it will act like any other app - open in the same window as last time. You don't really want to mess with that.

Add Comment ]

Post a comment





Leave this field empty: