Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 4139

Notice: The called constructor method for WP_Widget in mts_Widget_Tabs is deprecated since version 4.3.0! Use
__construct()
instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 3894

Notice: The called constructor method for WP_Widget in mts_ad_widget is deprecated since version 4.3.0! Use
__construct()
instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 3894

Notice: The called constructor method for WP_Widget in mts_ad_300_widget is deprecated since version 4.3.0! Use
__construct()
instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 3894

Notice: The called constructor method for WP_Widget in swt_tweet_widget is deprecated since version 4.3.0! Use
__construct()
instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 3894

Notice: The called constructor method for WP_Widget in Facebook_Like_Widget is deprecated since version 4.3.0! Use
__construct()
instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 3894
Identifying Multiple Screens with Adobe AIR

Identifying Multiple Screens with Adobe AIR


Notice: Undefined index: mts_posttop_adcode in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/single.php on line 19

While working on a presentation about Native Windows & Adobe AIR I ran into the Screen class. The screen object provides information about the display screens available to an application allowing you to position applications/windows on different screens. I say screens and not monitors because of a little caveat that the livedocs have in them:

Note that there is not necessarily a one-to-one correspondance between screens and the physical monitors attached to a computer. For example, two monitors may display the same screen.

I thought I’d have a little fun to get my code fingers back after a week in Cabo San Lucas, and create a little AIR app that identifies each screen. The basics are:

  1. Identify the Screens – I knew I had 2 screens, so that was easy. The screens property is an array of Screen objects, so you can work with as many as the user has.
  2. Create something to identify the windows – I used transparent windows with a label to make things simple.
  3. Then position the new windows on the screens.

[as]

private var _screenOne:Screen;
private var _screenTwo:Screen;

private function _identScreens( p_event:MouseEvent ):void
{
// I know I have 2 screens so I’ll just grab those
_screenOne = Screen.screens[0];
_screenTwo = Screen.screens[1];

// Now lets identify the screens
var identOne:IdentWindow = new IdentWindow();
identOne.title = “Screen One”;
identOne.screenLabel = “1”;

// open the irst window and set its position on the first screen
identOne.open( true );
identOne.nativeWindow.x = ( _screenOne.bounds.width / 2 ) – ( identOne.width / 2 );
identOne.nativeWindow.y = ( _screenOne.bounds.height / 2 ) – ( identOne.height / 2 );

var identTwo:IdentWindow = new IdentWindow();
identTwo.title = “Screen Two”
identTwo.screenLabel = “2”;

// open the second window and set its position on the second screen
identTwo.open( true );
identTwo.nativeWindow.x = ( _screenTwo.bounds.right – ( _screenTwo.bounds.width / 2 ) ) – ( identTwo.width / 2 );
identTwo.nativeWindow.y = ( _screenTwo.bounds.bottom / 2 ) – ( identTwo.height / 2 );
}
[/as]

Very straight forward and simple, but a fun little exercise.

You can download and install the app (with source) using the badge below:

[airbadge] Identify Screen Sample, http://www.thekuroko.com/wp-content/plugins/downloads-manager/upload/IdentifyScreens.air, 1.0, badge image.jpg[/airbadge]

Or, download the zip’ed flex archive:
[dm]2[/dm]


Notice: Undefined variable: defaults in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/functions.php on line 340

Notice: Undefined index: mts_postend_adcode in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/single.php on line 28

Notice: WP_Query was called with an argument that is deprecated since version 3.1.0! caller_get_posts is deprecated. Use ignore_sticky_posts instead. in /home1/jccrosby/public_html/admin.crsby.com/wp-includes/functions.php on line 4023

Leave a Reply

Your email address will not be published. Required fields are marked *