Graphics Programs Reference
In-Depth Information
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// create the viewer or object movement
var step:Number = 0; // step number for viewer movement
this.onEnterFrame = function()
{
// move the viewer towards the selected flag
var diffx = (viewer.dx - viewer.x)/viewerSpeed;
var diffy = (viewer.dy - viewer.y)/viewerSpeed;
var diffz = (viewer.dz - viewer.z)/viewerSpeed;
var difft = diffx + diffy + diffz;
viewer.x += diffx;
viewer.y += diffy;
viewer.z += diffz;
// test for end of viewer motion
// if it's done and zoomIn is true, then do it
if ( difft < 6 && (zoomIn == true ))
{
step++;
// temporarily increase z-value of the selected flag
zdata[mySelection-1]+= (200 - viewer.dz)/viewerSpeed;
// check to see if we have done all the steps
if (step == viewerSpeed )
{ zoomIn = false; // turn off zoom in
step = 0; // reset zoom step
// return the flag to its original depth
scene3D["object"+mySelection]swapDepths(oldDepth);
}
}
// zoom out when the background has been clicked
each frame, with its value getting progressively toward 200. This value is stored in the
zdata array in line 159 for use when the placeObj() and displayObj() functions are
called later. Once all the steps have been completed (line 162), zoomIn and step are
reset (lines 163 and 164), and the flag is assigned its original depth value.
Save your movie as 7_3_flagCam_DONE.fla and then test it to make sure everything is
working properly. When you click on a flag, you should get results similar to Figure 7.19.
Search WWH ::




Custom Search