Graphics Programs Reference
In-Depth Information
Step 5: Make a final adjustment
If you've done any experimenting with zooming the object or moving near the camera,
you will discover that things get a bit wacky. That's because we haven't put in any tests
for checking when we are too close, and it's something that should be done.
In the text layer, create a message that alerts the user to being too close to the
camera as shown in Figure 9.10. Choose Modify > Convert to Symbol. Create a movie
clip whose instance name is note_mc .
Figure 9.10 Creating an alert message
Let's add the necessary code to the script. Define a variable tooClose as shown in
line 10. We'll live dangerously and set the value to 5. Let's also start with the alert
note turned off (line 11).
7
8
9
10
11
12
// -------------------------------------------------------
// set the viewer parameters
var d:Number = 200; // distance from viewer to picture plane
var tooClose:Number = 5; // too close to camera distance
note_mc._visible = false;
A convenient place to test for being too close is in the findTheCenterPoint() function.
Inside this function, we are calculating the minimum and maximum z-values of the
object. Since the minimum z-value is the one closest to the camera, zmin is the value
to use with our test. If the object is too close, we will turn the alert note on and turn
the scene off. When the object is at an acceptable distance, we will turn the note off
and the scene on. Add the lines shown to the function.
 
Search WWH ::




Custom Search