Graphics Programs Reference
In-Depth Information
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// define the coordinate arrays
xdata = []; ydata = []; zdata = [];
// set the number of objects to be created
numberOfObjects = 24;
// add objects to the scene in 3D space
for ( var i:Number = 1; i <= numberOfObjects; i++)
{
scene3D.createEmptyMovieClip("object"+i,i);
scene3D["object"+i].loadMovie("flags/flag"+i+".png");
thisObj = scene3D["object"+i];
xdata[i-1] = i*100-1200; // -1100,...,1200
ydata[i-1] = 2400*Math.random()-1200; //-1200 < y < 1200
zdata[i-1] = 800 + 1000*Math.random(); // 800 < z < 1800
placeObj();
}
// place an object in 3D space
function placeObj()
{
thisObj.x = xdata[i-1];
thisObj.y = ydata[i-1];
thisObj.z = zdata[i-1];
}
The displayObj() function has nothing new. Since we will use the Up Arrow and Down
Arrow keys to enable the user to zoom in and out, we will only restrict the z-movement
of the viewer as shown in lines 46 and 47.
42
43
44
45
46
47
48
// display the 3d objects in the picture plane
function displayObj()
{
// restrict the viewer z-movement
if (viewer.z < -900 ) { viewer.z = -900 }
if (viewer.z > 1600 ) { viewer.z = 1600 }
 
Search WWH ::




Custom Search