Flash Player 10 3D settings with AS3/Flex

– taterboy | March 9th, 2010

Filed under: ActionScript 3, Flash, Flex, Tutorials

Flash Player 10’s 3D capabilities are pretty light, but they have opened up many possibilities in UI design. Getting the perspective just right will take some tweaks, so here’s a demo to show some of the inner workings, like focal length and field of view.

Using the PerspectiveProjection class is the key to getting 3D in Flash looking just right, it is also very easy to use.

?View Code ACTIONSCRIPT
//new PerspectiveProjection
var pers:PerspectiveProjection = new PerspectiveProjection();
 
//set the field of view - doesn't really do much
pers.fieldOfView = 55;//Default: 55, Range: 1 - 180
 
//set the focal length
pers.focalLength = 663;//Default: 663
 
//get stage center for a straight view, if you want a straight view.				
var centerX:Number = stage.stageWidth * 0.5;
var centerY:Number = stage.stageHeight * 0.5;
 
//set the projection center
pers.projectionCenter = new Point(centerX, centerY);
 
//assign to root/stage
//root.transform.perspectiveProjection = pers;
 
//assign to target/DisplayObject
triImage.transform.perspectiveProjection = pers;

See demo below.


Technorati Tags: , , , , , , ,

Other Related Articles:

| 2 Comments » | facebook:

2 Comments »

  1. Just as a side note:

    Both focalLength and fieldOfView adjusts the perspective distortion in a way that setting one of the values will override the other one!

    Thanks for the post!

    Comment by Paulo Amorim — September 23, 2010 @ 5:02 am

  2. Wow! This really is a single of the most effective blogs I’ve at any time appear throughout on this subject. Basically Magnificent

    Comment by Flv Player — November 3, 2010 @ 12:44 am

RSS feed for comments on this post. TrackBack URL

Leave a comment