Graphics Programs Reference
In-Depth Information
Figure 7.9 Initial screen of maskCamDone.fla
Step 7: Modify the user interaction
Now let's change the user interaction so that the cursor controls both our left and right
movement and our up and down movement. Here's how we'll do it. We'll check to see
where the cursor is in relation to the center of the scene to determine which way to
move. If the cursor is to the right of the scene center, the difference between the two is
positive and the movement will be to the right. If the cursor is to the left of the scene
center, the difference between the two is negative and the movement will be to the left.
The difference is divided by the viewerSpeed so that the movement isn't too rapid. The
viewerSpeed can be adjusted to suit taste. The vertical movement is handled similarly.
75
76
77
78
79
80
81
// create the viewer or object movement
this.onEnterFrame = function()
{
// use mouse for horizontal & vertical viewer movement
viewer.x += (_xmouse - scene3D._x)/viewerSpeed;
viewer.y += -(_ymouse - scene3D._y)/viewerSpeed;
We will continue to use the Up Arrow and Down Arrow keys to zoom in and out. Delete
the two lines that use the Right Arrow and Left Arrow keys to control horizontal move-
ment (lines 85 and 86).
 
Search WWH ::




Custom Search