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

Controlling Stage scaling<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Wh<strong>en</strong> the portion of the scre<strong>en</strong> repres<strong>en</strong>ting Flash Player or AIR is resized, the runtime automatically adjusts the Stage<br />

cont<strong>en</strong>ts to comp<strong>en</strong>sate. The Stage class’s scaleMode property determines how the Stage cont<strong>en</strong>ts are adjusted. This<br />

property can be set to four differ<strong>en</strong>t values, defined as constants in the flash.display.StageScaleMode class:<br />

StageScaleMode.EXACT_FIT scales the SWF to fill the new stage dim<strong>en</strong>sions without regard for the original<br />

cont<strong>en</strong>t aspect ratio. The scale factors might not be the same for width and height, so the cont<strong>en</strong>t can appear<br />

squeezed or stretched if the aspect ratio of the stage is changed.<br />

StageScaleMode.SHOW_ALL scales the SWF to fit <strong>en</strong>tirely within the new stage dim<strong>en</strong>sions without changing the<br />

cont<strong>en</strong>t aspect ratio. This scale mode displays all of the cont<strong>en</strong>t, but can result in “letterbox” borders, like the black<br />

bars that appear wh<strong>en</strong> viewing a wide-scre<strong>en</strong> movie on a standard television.<br />

StageScaleMode.NO_BORDER scales the SWF to <strong>en</strong>tirely fill the new stage dim<strong>en</strong>sions without changing the aspect<br />

ratio of the cont<strong>en</strong>t. This scale mode makes full use of the stage display area, but can result in cropping.<br />

StageScaleMode.NO_SCALE — does not scale the SWF. If the new stage dim<strong>en</strong>sions are smaller, the cont<strong>en</strong>t is<br />

cropped; if larger, the added space is blank.<br />

In the StageScaleMode.NO_SCALE scale mode only, the stageWidth and stageHeight properties of the Stage class<br />

can be used to determine the actual pixel dim<strong>en</strong>sions of the resized stage. (In the other scale modes, the stageWidth<br />

and stageHeight properties always reflect the original width and height of the SWF.) In addition, wh<strong>en</strong><br />

scaleMode is set to StageScaleMode.NO_SCALE and the SWF file is resized, the Stage class’s resize ev<strong>en</strong>t is<br />

dispatched, allowing you to make adjustm<strong>en</strong>ts accordingly.<br />

Consequ<strong>en</strong>tly, having scaleMode set to StageScaleMode.NO_SCALE allows you to have greater control over how<br />

the scre<strong>en</strong> cont<strong>en</strong>ts adjust to the window resizing if you desire. For example, in a SWF containing a video and a<br />

control bar, you might want to make the control bar stay the same size wh<strong>en</strong> the Stage is resized, and only change<br />

the size of the video window to accommodate the Stage size change. This is demonstrated in the following example:<br />

Last updated 6/6/2012<br />

165

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

Saved successfully!

Ooh no, something went wrong!