Graphics Programs Reference
In-Depth Information
Step 2: Define the coordinates of the object
An Actions window will appear. We will create an array named points as shown in line
2, and then assign the x- and y-coordinates of the object to the elements of the array.
The coordinates should be entered in order, preferably counterclockwise to be consis-
tent with later programs we will be using. The file is saved as planeDataZ.as . It is
critical that the .as suffix be used, as Flash requires it. Setting up the file in this manner
makes it easy to access the coordinates of the object.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// define the coordinates of the plane shape
points = new Array();
points[0]= { x: 0, y: 0 }
points[1]= { x:200, y: 0 }
points[2]= { x:200, y: 50 }
points[3]= { x: 70, y: 50 }
points[4]= { x:200, y:200 }
points[5]= { x:200, y:250 }
points[6]= { x: 0, y:250 }
points[7]= { x: 0, y:200 }
points[8]= { x:130, y:200 }
points[9]= { x: 0, y: 50 }
Step 3: Include the ActionScript files and set viewer parameters
Now that we have the buttons and data out of the way, we're ready to look at the pro-
gram. Open planarLines3D.swf for an example of where we are heading and open
planarLines3D.fla to follow the discussion here. We'll start by including our object
data (line 2) and the button actions (line 5). The syntax for the include is very specific
and must begin with a # character and have the name of the ActionScript file in quotes.
1
2
3
4
5
6
7
8
9
10
// include the object data
#include "planeDataZ.as"
// include the button actions
#include "3Dbuttons.as"
// -------------------------------------------------------
// set the viewer parameters
var d:Number = 200; // distance from viewer to picture plane
Search WWH ::




Custom Search