Graphics Programs Reference
In-Depth Information
A similar process can be used to put restrictions on the x-movement shown in lines 57
and 58. The results are shown in Figure 7.11 for the worst cases of maximum zoom.
56
57
58
59
// restrict the viewer x-movement
if (viewer.x < -1000 ) { viewer.x = -1000 }
if (viewer.x > 1200 ) { viewer.x = 1200 }
Note that the numbers selected to be used are not cast in stone but rather depend on
how much movement you would like the objects to have. The main objective is to pre-
vent the user from losing control by having the objects go entirely off the screen. Test
your movie and verify that the test is working.
Figure 7.11 The masks at minimum and maximum viewer.x values and maximum zoom
As a last step, similar restrictions can be placed on the y-movement shown in lines 61
and 62. The results are shown in Figure 7.12 for the worst cases of maximum zoom.
Save and test your movie to make sure that everything works as it should.
60
61
62
63
// restrict the viewer y-movement
if (viewer.y < -300 ) { viewer.y = -300 }
if (viewer.y > 300 ) { viewer.y = 300 }
Tip: The user interaction above is defined by the movement of the viewer, but there
are other possibilities. For example, by changing the expressions for viewer.x and
viewer.y from += to -= in the onEnterFrame handler will cause the objects to appear
to be following the cursor. Another good approach is to reverse the y and z interaction
 
Search WWH ::




Custom Search