package { import flash.display.Shape; import flash.display.Sprite; import flash.geom.PerspectiveProjection; import flash.geom.Point; [SWF(width=600, height=400, backgroundColor=0x000000)] /** * Demonstrates how different fields of view can affect shapes drawn in 3D. */ public class graphic_flex_image_effects_06_Flex_FieldOfViewTest extends Sprite { /** * Constructor. Creates new PerspectiveProjection for this sprite, * then draws 3 planes in 3D space. */ public function graphic_flex_image_effects_06_Flex_FieldOfViewTest() { var projection:PerspectiveProjection = new PerspectiveProjection(); projection.projectionCenter = new Point(stage.stageWidth/2, stage.stageHeight/2); // alter field of view to see effects projection.fieldOfView = 150; transform.perspectiveProjection = projection; createPlane(0xFF0000, 100, 200, 100, -45); createPlane(0xFF0000, 300, 200, 180, 0); createPlane(0xFF0000, 500, 200, 100, 45); } /** * Creates a plane of the specified color at the specified position and rotation. * * @param color The color of the plane. * @param x The x position of the plane. * @param y The y position of the plane. * @param z The z position of the plane. * @param rotationY The rotation of the plane on the y axis. */ private function createPlane( color:uint, x:Number, y:Number, z:Number, rotationY:Number ):void { var plane:Shape = new Shape(); plane.graphics.beginFill(color); plane.graphics.drawRect(-100, -100, 200, 200); plane.graphics.endFill(); plane.x = x; plane.y = y; plane.z = z; plane.rotationY = rotationY; addChild(plane); } } }