Adobe AIR 1.5 Cookbook
by Rich Tretola, David Tucker, Marco Casario, Koen DeWeggheleire, Koen De Weggheleire
Chapter 4. Screens
Breaking out of the browser provides you with additional challenges when developing applications. In addition to positioning elements within your application, you now have control over where the application itself is positioned. In addition, you now have to expand your thinking beyond a browser window to a user’s desktop, which consists of one or more monitors.
The Screen class in Adobe AIR provides you with information about the current
user’s monitor setup. This allows you to take advantage of the full
capability of the user’s desktop, including multiple monitor configurations.
By using the data contained in this class, you can get explicit information
about the number of monitors, the positioning of these monitors, and even
the capabilities of the monitors themselves.
Positioning Windows on the Desktop
Problem
You want to center your application on the user’s primary monitor.
Solution
Use the Screen class to
determine the width and height of the primary monitor on the user’s
computer. Using this information, you can position your application in
the center of the screen.
Discussion
The Screen class has properties
that reflect characteristics of the user’s primary monitor and provides
an instance of itself in the static variable Screen.mainScreen. Included in these
properties are two variables that define the width and height of the
monitor: bounds and visibleBounds.
bounds: Theboundsproperty of theScreenclass is an instance of theRectangleclass, which provides ...