Graphics Programs Reference
In-Depth Information
Before we can actually draw, we need to tell Flash what we want the lines that we will
be drawing to look like. The lineStyle() method serves this purpose (line 172). The
first parameter is the line thickness and may be any integer between 0 and 255. The
second parameter is the RGB color of the line value expressed as a hexadecimal color
value. If nothing is specified, the default color is black. The third parameter is optional
and specifies the alpha of the color using an integer between 0 (transparent) and 100
(opaque). Our values specify an opaque, pure blue line that is 2 pixels wide.
To begin drawing, we first issue a moveTo(xs[0],ys[0]) method that moves to the
first screen coordinate (line 174). Next, we set up a for loop that loops over the
number of points in the screen coordinate arrays (line 175). For each point in the
loop, a line is drawn from the previous location to the current location using the
lineTo(xs[n],ys[n]) method (line 177). After the loop is done, we draw a line
to the first point with a lineTo(xs[0],ys[0]) in line 179.
Step 10: Update the object
As a final step, we want an onEnterFrame handler to enable us to use the buttons to
animate the object by moving, rotating, and scaling it. We just need to make calls to
those functions that will enable us to carry that out. Each time we enter a frame, we
need to find the new location of the center point, get new values for the screen coordi-
nates, and draw the lines of the object.
183
184
185
186
187
188
189
190
191
// ------------------------------------------------------
// update the object
this.onEnterFrame = function()
{
findTheCenterPoint();
getScreenCoords();
drawLines();
}
Tip: Make a one-line change to the program that will load the object data found in the
file planeDataF.as . Get a sense of what each button does to transform the object.
Note the difference between moving the camera distance to change the focal length
and moving the object in and out along the z-axis.
Search WWH ::




Custom Search