13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Display programming<br />

monitors, the SWF cont<strong>en</strong>t expands to fill only one monitor. Flash Player and AIR use a metric to determine which<br />

monitor contains the greatest portion of the SWF, and uses that monitor for full-scre<strong>en</strong> mode. The fullScre<strong>en</strong>Height<br />

and fullScre<strong>en</strong>Width properties only reflect the size of the monitor that is used for full-scre<strong>en</strong> mode. For more<br />

information, see Stage.fullScre<strong>en</strong>Height and Stage.fullScre<strong>en</strong>Width in the ActionScript 3.0 Refer<strong>en</strong>ce for the<br />

Adobe Flash Platform.<br />

Stage scaling behavior for full-scre<strong>en</strong> mode is the same as under normal mode; the scaling is controlled by the Stage<br />

class’s scaleMode property. If the scaleMode property is set to StageScaleMode.NO_SCALE, the Stage’s stageWidth<br />

and stageHeight properties change to reflect the size of the scre<strong>en</strong> area occupied by the SWF (the <strong>en</strong>tire scre<strong>en</strong>, in<br />

this case); if viewed in the browser the HTML parameter for this controls the setting.<br />

You can use the Stage class’s fullScre<strong>en</strong> ev<strong>en</strong>t to detect and respond wh<strong>en</strong> full-scre<strong>en</strong> mode is turned on or off. For<br />

example, you might want to reposition, add, or remove items from the scre<strong>en</strong> wh<strong>en</strong> <strong>en</strong>tering or leaving full-scre<strong>en</strong><br />

mode, as in this example:<br />

import flash.ev<strong>en</strong>ts.FullScre<strong>en</strong>Ev<strong>en</strong>t;<br />

function fullScre<strong>en</strong>Redraw(ev<strong>en</strong>t:FullScre<strong>en</strong>Ev<strong>en</strong>t):void<br />

{<br />

if (ev<strong>en</strong>t.fullScre<strong>en</strong>)<br />

{<br />

// Remove input text fields.<br />

// Add a button that closes full-scre<strong>en</strong> mode.<br />

}<br />

else<br />

{<br />

// Re-add input text fields.<br />

// Remove the button that closes full-scre<strong>en</strong> mode.<br />

}<br />

}<br />

mySprite.stage.addEv<strong>en</strong>tList<strong>en</strong>er(FullScre<strong>en</strong>Ev<strong>en</strong>t.FULL_SCREEN, fullScre<strong>en</strong>Redraw);<br />

As this code shows, the ev<strong>en</strong>t object for the fullScre<strong>en</strong> ev<strong>en</strong>t is an instance of the flash.ev<strong>en</strong>ts.FullScre<strong>en</strong>Ev<strong>en</strong>t class,<br />

which includes a fullScre<strong>en</strong> property indicating whether full-scre<strong>en</strong> mode is <strong>en</strong>abled (true) or not (false).<br />

Keyboard support in full-scre<strong>en</strong> mode<br />

Wh<strong>en</strong> Flash Player runs in a browser, all keyboard-related ActionScript, such as keyboard ev<strong>en</strong>ts and text <strong>en</strong>try in<br />

TextField instances, is disabled in full-scre<strong>en</strong> mode. The exceptions (the keys that are <strong>en</strong>abled) are:<br />

Selected non-printing keys, specifically the arrow keys, space bar, and tab key<br />

Keyboard shortcuts that terminate full-scre<strong>en</strong> mode: Esc (Windows and Mac), Control-W (Windows), Command-<br />

W (Mac), and Alt-F4<br />

These restrictions are not pres<strong>en</strong>t for SWF cont<strong>en</strong>t running in the stand-alone Flash Player or in AIR. AIR supports<br />

an interactive full-scre<strong>en</strong> mode that allows keyboard input.<br />

Mouse support in full-scre<strong>en</strong> mode<br />

By default, mouse ev<strong>en</strong>ts in full-scre<strong>en</strong> mode work the same way as wh<strong>en</strong> not in full-scre<strong>en</strong> mode. However, in fullscre<strong>en</strong><br />

mode, you can optionally set the Stage.mouseLock property to <strong>en</strong>able mouse locking. Mouse locking disables<br />

the cursor and <strong>en</strong>ables unbounded mouse movem<strong>en</strong>t.<br />

Note: You can only <strong>en</strong>able mouse locking in full-scre<strong>en</strong> mode for desktop applications. Setting it on applications not in<br />

full-scre<strong>en</strong> mode, or for applications on mobile devices, throws an exception.<br />

Last updated 6/6/2012<br />

169

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!