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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Working in three dim<strong>en</strong>sions (3D)<br />

You can instantiate your own PerspectiveProjection object with the int<strong>en</strong>tion of modifying the projectionC<strong>en</strong>ter<br />

and fieldOfView yourself. In this case, the default values of the newly created object are the following, based on a<br />

default stage size of 500 by 500:<br />

fieldOfView: 55<br />

perspectiveC<strong>en</strong>ter: 250,250<br />

focalL<strong>en</strong>gth: 480.24554443359375<br />

Example: Perspective projection<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

The following example demonstrates the use of perspective projection to create 3D space. It shows how you can modify<br />

the vanishing point and change the perspective projection of the space through the projectionC<strong>en</strong>ter property. This<br />

modification forces the recalculation of the focalL<strong>en</strong>gth and fieldOfView with its concomitant distortion of the 3D<br />

space.<br />

This example:<br />

1 Creates a sprite named c<strong>en</strong>ter, as a circle with cross hairs<br />

2 Assigns the coordinates of the c<strong>en</strong>ter sprite to the projectionC<strong>en</strong>ter property of the perspectiveProjection<br />

property of the transform property of the root<br />

3 Adds ev<strong>en</strong>t list<strong>en</strong>ers for mouse ev<strong>en</strong>ts that call handlers that modify the projectionC<strong>en</strong>ter so that it follows the<br />

location of the c<strong>en</strong>ter object<br />

4 Creates four accordion-style boxes that form the walls of the perspective space<br />

Wh<strong>en</strong> you test this example, ProjectionDragger.swf, drag the circle around to differ<strong>en</strong>t locations. The vanishing point<br />

follows the circle, landing wherever you drop it. Watch the boxes that <strong>en</strong>close the space stretch and become distorted<br />

wh<strong>en</strong> you move the projection c<strong>en</strong>ter far from the c<strong>en</strong>ter of the stage.<br />

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The<br />

ProjectionDragger application files are in the Samples/ProjectionDragger folder.<br />

Last updated 6/6/2012<br />

357

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

Saved successfully!

Ooh no, something went wrong!