Graphics Programs Reference
In-Depth Information
Save your movie as 7_1_puppyCam_DONE.fla and test your movie with the arrow
keys. When you use the Up Arrow and Down Arrow keys, the objects grow and shrink
as expected. Notice that as you use the Left Arrow and Right Arrow keys to move the
camera horizontally, the adjustment for parallax scrolling occurs automatically. This
provides a very strong perception of the puppies being in a 3D environment.
Notice also that when you use the Left Arrow key, the objects appear to move to the
right as shown in Figure 7.2. Is this what you expected to happen? Some people are
surprised by the movement, others assume it. There's not necessarily a correct answer,
but it should be something to think about when setting up a user interaction and the
instructions that you provide.
Figure 7.2 Effect of moving the camera horizontally to the left
Step 4: Make a minor adjustment
Recall that in the previous chapter, we needed a test to keep objects from getting too
close to the camera so they wouldn't flip over and come back into the scene belly up.
We need a similar test here, but we have to be a little careful. We may not want to see
a puppy that gets too close when the camera is zooming in, but when we zoom back
out, we expect that puppy to still be there and to see it. We can have what we want
by turning the visibility of any puppy on and off. We just need to modify our script by
inserting a few lines as shown below.
40
41
42
43
44
45
// check if the object is too close to the viewer
if (thisObj.z <= -d + 40)
{ thisObj._visible = false; }
else thisObj._visible = true;
// calculate the distance ratio dr
 
Search WWH ::




Custom Search