Graphics Programs Reference
In-Depth Information
already defined, we can just add a color property to it and then specify the color we
want for each plane.
28
29
30
31
32
33
34
// -------------------------------------------------------
// define the object in 3D space
var numPts:Number = x.length;
var numPlanes:Number = planes.length;
planes.col = [ 0x6666cc,0x66cc66,0x66cccc,
0xcc6666,0xcc66cc,0xcccc66
]
Step 2: Modify the drawPlanes function
The hard part of deciding the colors for each plane was in the last step. Here, we just
need to change the beginFill() method as shown, and we're done.
267
268
269
270
271
for ( k = 0; k < 4; k++) { p[k] = planes[n][k]; }
lineStyle (2, 0x6600cc, 100);
beginFill (planes.col[n], 50);
// get screen coordinates and draw the plane
Save your movie as 9_5_colorsDONE.fla and check it out.
Step 3: Use mouse control to spin the cube
It is easy to use the button actions for other types of user interaction such as move-
ment of the mouse. Add the two-line change below to put the y-axis angle of rotation
and the x-axis angle of rotation under mouse control. The farther the cursor is from
the center of the Stage, the faster the cube will spin.
286
287
288
289
290
291
this.onEnterFrame = function()
{
ry = (_xmouse - Stage.width/2)/100%360;
rx = (_ymouse - Stage.height/2)/100%360;
findTheCenterPoint();
Save your movie as 9_5_mouseDONE.fla . Test it and watch it spin.
 
Search WWH ::




Custom Search