Graphics Programs Reference
In-Depth Information
Step 11: Define the panRight() function
Add the lines below to your script. When the cursor is on the right side of the screen,
we want to simulate a viewer turning right. The visual equivalent of that panning
motion is to move the image to the left (line 28).
26
27
28
29
30
31
panRight = function()
{
pano_mc._x -= moveAmount;
if (pano_mc._x < xmin) { pano_mc._x += pano_mc._width/2 }
}
If we move the image all the way over to xmin and find its identical spot in the other
half of the panorama movie clip, we again find that the jump is half the width of the
panorama as before, only with a change of sign. Thus, the two panning functions have
similar expressions as we would expect. They only differ in their plus and minus signs.
Note that this process is essentially the same as we went through for parallax scrolling
in Chapter 4.
Step 12: Define the dontPan() function
Here's a function you'll really like, one that does nothing at all. There are times when
it's nice to do nothing.
32
33
34
35
36
dontPan = function()
{
}
Save your file as 8_3_panoDONE.fla and check to make sure that it pans in both direc-
tions continuously. Is there a place where you do nothing?
Step 13: Add arrow cursors
Now that we have everything functioning, let's enhance the user interaction. It would
be good to provide some visual feedback in the form of arrows whenever the cursor is
in one of the hot spot areas. We can use the arrows like a cursor by hiding the regular
mouse cursor and setting the arrows to have the same location as the cursor.
Search WWH ::




Custom Search