A user of Focus Booster sent through an interesting request, which is to make Focus Booster restore the window position upon subsequent loads. I can’t believe I hadn’t thought of that, and have now added it to my list of required standard functionality for AIR applications.
So, I set out to implement this feature and got to thinking about multi-screen support. Everything screen related takes place in the flash.display.Screen class. I thought there might be a simple method or property to return the current screen index a particular nativeWindow is on; but there isn’t really anything quite that useful there.
The closest thing you can get is Screen.screens which is an array containing individual Screen objects, one for each screen plugged into the viewing computer. From there, you have to implement your own routines to determine which screen a nativeWindow is on.
I wrote up a quick example that demonstrates how to determine which screen the window is on, and also how to store the window position and restore it next time the application is loaded. It’s called TwoScreens, and you can right-click to view the source (once you’ve unzipped the AIR file and installed it).
There may be a better way to do this, so post a comment if you know better ways to achieve this.
Filed under: ActionScript, air, flex