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 />

Mouse locking is disabled automatically and the mouse cursor is made visible again wh<strong>en</strong>:<br />

The user exits full-scre<strong>en</strong> mode by using the Escape key (all platforms), Control-W (Windows), Command-W<br />

(Mac), or Alt-F4 (Windows).<br />

The application window loses focus.<br />

Any settings UI is visible, including all privacy dialog boxes.<br />

A native dialog box is shown, such as a file upload dialog box.<br />

Ev<strong>en</strong>ts associated with mouse movem<strong>en</strong>t, such as the mouseMove ev<strong>en</strong>t, use the MouseEv<strong>en</strong>t class to repres<strong>en</strong>t the<br />

ev<strong>en</strong>t object. Wh<strong>en</strong> mouse locking is disabled, use the MouseEv<strong>en</strong>t.localX and MouseEv<strong>en</strong>t.localY properties to<br />

determine the location of the mouse.Wh<strong>en</strong> mouse locking is <strong>en</strong>abled, use the MouseEv<strong>en</strong>t.movem<strong>en</strong>tX and<br />

MouseEv<strong>en</strong>t.movem<strong>en</strong>tY properties to determine the location of the mouse. The movem<strong>en</strong>tX and movem<strong>en</strong>tY<br />

properties contain changes in the position of the mouse since the last ev<strong>en</strong>t, instead of absolute coordinates of the<br />

mouse location.<br />

Hardware scaling in full-scre<strong>en</strong> mode<br />

You can use the Stage class’s fullScre<strong>en</strong>SourceRect property to set Flash Player or AIR to scale a specific region of<br />

the stage to full-scre<strong>en</strong> mode. Flash Player and AIR scale in hardware, if available, using the graphics and video card<br />

on a user's computer, and g<strong>en</strong>erally display cont<strong>en</strong>t more quickly than software scaling.<br />

To take advantage of hardware scaling, you set the whole stage or part of the stage to full-scre<strong>en</strong> mode. The following<br />

ActionScript 3.0 code sets the whole stage to full-scre<strong>en</strong> mode:<br />

import flash.geom.*;<br />

{<br />

stage.fullScre<strong>en</strong>SourceRect = new Rectangle(0,0,320,240);<br />

stage.displayState = StageDisplayState.FULL_SCREEN;<br />

}<br />

Wh<strong>en</strong> this property is set to a valid rectangle and the displayState property is set to full-scre<strong>en</strong> mode, Flash Player<br />

and AIR scale the specified area. The actual Stage size in pixels within ActionScript does not change. Flash Player and<br />

AIR <strong>en</strong>force a minimum limit for the size of the rectangle to accommodate the standard “Press Esc to exit full-scre<strong>en</strong><br />

mode” message. This limit is usually around 260 by 30 pixels but can vary dep<strong>en</strong>ding on platform and Flash Player<br />

version.<br />

The fullScre<strong>en</strong>SourceRect property can only be set wh<strong>en</strong> Flash Player or AIR is not in full-scre<strong>en</strong> mode. To use<br />

this property correctly, set this property first, th<strong>en</strong> set the displayState property to full-scre<strong>en</strong> mode.<br />

To <strong>en</strong>able scaling, set the fullScre<strong>en</strong>SourceRect property to a rectangle object.<br />

stage.fullScre<strong>en</strong>SourceRect = new Rectangle(0,0,320,240);<br />

To disable scaling, set the fullScre<strong>en</strong>SourceRect property to null.<br />

stage.fullScre<strong>en</strong>SourceRect = null;<br />

To take advantage of all hardware acceleration features with Flash Player, <strong>en</strong>able it through the Flash Player Settings<br />

dialog box. To load the dialog box, right-click (Windows) or Control-click (Mac) inside Flash Player cont<strong>en</strong>t in your<br />

browser. Select the Display tab, which is the first tab, and click the checkbox: Enable hardware acceleration.<br />

Direct and GPU-compositing window modes<br />

Flash Player 10 introduces two window modes, direct and GPU compositing, which you can <strong>en</strong>able through the<br />

publish settings in the Flash authoring tool. These modes are not supported in AIR. To take advantage of these modes,<br />

you must <strong>en</strong>able hardware acceleration for Flash Player.<br />

Last updated 6/6/2012<br />

170

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

Saved successfully!

Ooh no, something went wrong!