Experiment 2 - When PerspectiveProjection is assigned to a 3D Object

The code for the applet below is basically the same as the code for the applet on the first page, except for changes in fieldOfView for pp1, pp2, and the root object explained below, and new buttons that test different things.

Changes in the Code

The file in the pp.zip corresponding to thes experiment is pp_show2.fla. For clearer effects, we vary in this applet values of the fieldOfView property of pp1, pp2, and this.transform.perspectiveProjection.

var pp1:PerspectiveProjection=new PerspectiveProjection();


pp1.projectionCenter=new Point(0,0);

var pp2:PerspectiveProjection=new PerspectiveProjection();


pp2.projectionCenter=new Point(0,0);




We have two buttons: btn3D which changes container1 into a 3D object and btn2D which makes container2 back into a 2D object.



function btn3DClick(e:MouseEvent):void {


//After the z coordinate is assigned, container1 becomes a 3D object.





function btn2DClick(e:MouseEvent):void {


//container1 is now a 2D object as its matrix3D is null.




When container1 to which pp1 is assigned changes into a 3D object, the coordinates (0,0) of pp1.projectionCenter are interpreted as coordinates relative to the MainTimeline. Thus, the vanishing point moves to the upper left corner of the stage. fieldOfView remains unaffected at 130.


  • Download all the source files corresponding to this tutorial: pp.zip

On the next page we leave containers but assign PerspectiveProjection to holder1 and holder2. Some interesting effects occur.

Back to Flash CS4 Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.