Graphics Programs Reference
In-Depth Information
31
32
33
34
35
36
37
38
39
40
41
checkTheMouse = function()
{
cursor_mc._x = _xmouse;
cursor_mc._y = _ymouse;
moveAmount = Math.abs(_xmouse - startX)/speedFactor;
if (_xmouse < startX - 10) { panLeft() }
else if (_xmouse > startX + 10 ) { panRight() }
else dontPan();
}
Step 7: Define the panorama vertical limits
Now that we have a handle on panning, let's begin to look at vertical scrolling. The ad-
ditional scripting that we will need is very similar to what you already have. We'll need
some vertical limits on the panorama just as we have horizontal limits. At the same time,
it might be helpful to clean up the beginning of the script for better readability. The
determination of ymax and ymin is similar to xmax and xmin .
1
2
3
4
5
6
7
8
9
10
11
// initialize variables
var moveAmount:Number = 10; // how fast the pano will move
var centerX:Number = Stage.width/2; // horiz. center of Stage
var xmax:Number = pano_mc._width/2; // max x-position of pano
var xmin:Number = Stage.width-xmax; // min x-position of pano
var ymax:Number = pano_mc._height/2; // max y-position of pano
var ymin:Number = Stage.height-ymax; // min y-position of pano
var pressed:Boolean = false; // used for pressing mouse down
var speedFactor:Number = 20; // used to control panning speed
Step 8: Test for vertical scrolling
We have to add a test for scrolling vertically in the checkTheMouse handler similar to
that for panning horizontally. At this point, instead of simply defining a moveAmount ,
we will make a distinction between the horizontal move amount, xmoveAmount , and
the vertical move amount, ymoveAmount .
 
Search WWH ::




Custom Search