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

Stage dim<strong>en</strong>sion changes<br />

Wh<strong>en</strong> the stage dim<strong>en</strong>sions change, the stage cont<strong>en</strong>ts are scaled and repositioned as specified by the scaleMode and<br />

align properties of the Stage object. In most cases, relying on the automatic behavior provided by the Stage<br />

scaleMode settings does not produce good results. Instead you must re-layout or redraw your graphics and<br />

compon<strong>en</strong>ts to support more than one aspect ratio. (Providing flexible layout logic also means that your application<br />

will work better across devices with differ<strong>en</strong>t scre<strong>en</strong> sizes and aspect ratios.)<br />

The following illustration demonstrates the effects of the differ<strong>en</strong>t scaleMode settings wh<strong>en</strong> rotating a typical mobile<br />

device:<br />

Rotation from landscape to portrait aspect ratio<br />

The illustration demonstrates the scaling behavior that occurs wh<strong>en</strong> rotating from a landscape aspect ratio to a portrait<br />

aspect ratio with differ<strong>en</strong>t scale modes. Rotating from portrait to landscape causes a similar set of effects.<br />

Ori<strong>en</strong>tation change ev<strong>en</strong>ts<br />

The Stage object dispatches two types of ev<strong>en</strong>ts that you can use to detect and react to ori<strong>en</strong>tation changes. Both stage<br />

resize and ori<strong>en</strong>tationChange ev<strong>en</strong>ts are dispatched wh<strong>en</strong> auto-ori<strong>en</strong>tation is <strong>en</strong>abled.<br />

The resize ev<strong>en</strong>t is the best ev<strong>en</strong>t to use wh<strong>en</strong> you are relying on auto-ori<strong>en</strong>tation to keep the display upright. Wh<strong>en</strong><br />

the stage dispatches a resize ev<strong>en</strong>t, relayout or redraw your cont<strong>en</strong>t, as needed. The resize ev<strong>en</strong>t is only dispatched<br />

wh<strong>en</strong> the stage scale mode is set to noScale.<br />

The ori<strong>en</strong>tationChange ev<strong>en</strong>t can also be used to detect ori<strong>en</strong>tation changes. The ori<strong>en</strong>tationChange ev<strong>en</strong>t is only<br />

dispatched wh<strong>en</strong> auto-ori<strong>en</strong>tation is <strong>en</strong>abled.<br />

Note: On some mobile platforms, the stage dispatches a cancelable ori<strong>en</strong>tationChanging ev<strong>en</strong>t before dispatching the<br />

resize or ori<strong>en</strong>tationChange ev<strong>en</strong>ts. Since the ev<strong>en</strong>t is not supported on all platforms, avoid relying on it.<br />

Last updated 6/6/2012<br />

196

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

Saved successfully!

Ooh no, something went wrong!