Graphics Programs Reference
In-Depth Information
Step 6: Display the objects
The next thing we need to do is modify the script to display the objects. Looking at
the script, you might expect that the displayObj() function will require some adjust-
ments, but it is fine for now. If you think about it, that may not be too surprising since
the process for converting 3D coordinates to screen coordinates remains the same.
Where we must make a few changes is in the onEnterFrame handler. For the time
being, we will keep the same user interactivity with the arrow keys just to make sure
the movie is working fine overall. The first line that needs some adjusting is where we
loop over the objects to display them (line 85). We need to modify the for loop com-
mand as before to account for the fact that the numbering of our objects begins with
1 and ends with the number of objects specified.
We also need to insert a call to the placeObj() function (line 88) before we place a call
to the displayObj() function. This is a little strange, since it would seem that once the
object has been assigned its 3D coordinates as properties, it should be able to remem-
ber them. However, this is not the case, and it is apparently related to the fact that
each object has an image loaded into it. Since an image loaded into a movie clip inher-
its the position, rotation, and scale properties of the movie clip, the added complexity
requires resetting the position each time the frame is entered.
84
85
86
87
88
89
90
// loop over the objects and display them
for (i=1; i<=numberOfObjects; i++)
{
thisObj = scene3D["object"+i];
placeObj();
displayObj();
}
Save your movie as 7_2_maskCam_DONE.fla and test it. Your initial screen should
appear as in Figure 7.9. Using the arrow keys, you should be able to zoom in and out
as well as move left and right.
Notice that in Figure 7.9, the masks are off center. This may be surprising since the
x-coordinates of the masks are symmetric about the origin. The reason for this is that
the registration points of the images that were loaded are set to the upper-left corner.
The upper-left corner of the middle mask is in the middle of the Stage. This offset is not
critical because of our final mouse interaction and could easily be corrected if needed.
 
Search WWH ::




Custom Search