Graphics Programs Reference
In-Depth Information
to its values in the Properties window. The y - value of the top of the ellipse is 215 in
Flash coordinates, which becomes a negative number in screen coordinates. The height
of the ellipse is 200, so the bottom of the ellipse is located at 415 in Flash coordinates
and -415 in screen coordinates.
In the side view, if we extend lines from the viewer's eye through the points -215 and
-415, the intersections of these lines with projected lines of the circular path from the
top view will give us the vertical location of the x-z plane of the path. We could use trig
to figure out this value, but we can just as easily read the value from the rulers in the
drawing and see that -280 is close enough. Enter the values below for the path charac-
teristics and delete the remaining 2D script, which will be replaced with our 3D script.
8
9
10
11
12
13
// define the path characteristics
var xc:Number = 0; // xc = horizontal center of path
var yc:Number = -280; // yc = vertical center of path
var zc:Number = 0; // zc = depth center of path
var r:Number = 200; // r = path radius
Step 3: Place the object on the path of motion
As we have done before, let's create a function to place the object on the circular path.
We need to place it in 3D space, so we will define x-, y-, and z-properties that will con-
tain the 3D coordinates of the object as shown below. Note that because we are follow-
ing a circle in the x-z plane, we can use the standard trig functions for a circle using x
and z. The y-value just specifies where the circular plane is located vertically. Notice
that in earlier versions of the placeObj() function, we had nothing inside the parenthe-
ses. Here we are using the generic name thisObj to represent any object that we may
care to use with this function. Items like this are often referred to as arguments.
14
15
16
17
18
19
20
21
22
23
24
// place the object on the path of motion
// angle is starting angle of the object on the path
var angle:Number = 0;
function placeObj(thisObj)
{
var a:Number = angle*Math.PI/180;
thisObj.x = xc + r * Math.cos(a);
thisObj.y = yc;
thisObj.z = zc + r * Math.sin(a);
}
Search WWH ::




Custom Search