Graphics Programs Reference
In-Depth Information
We needed to scale the image down initially to create the double panorama because of
size limitations in Flash. By setting the size sufficiently small when creating the movie
clip and then later scaling up, Flash can handle the large image size. It's a little strange,
but it works.
Step 5: Add the beginning script
It's time to do a little scripting. We'll begin by initializing a few variables that we will
need shortly.
1
2
3
4
5
6
// 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 position of pano
var xmin:Number = Stage.width - maxX; // min position of pano
The moveAmount variable controls how fast the pano moves left and right. The horizontal
center of the Stage is placed in centerX . The variables xmax and xmin are restrictions
that will be placed on the position of the panorama.
Step 6: Add the panorama onEnterFrame handler
As mentioned earlier, we want the image to move to the right or left when the user
moves the mouse over the left or right side of the Stage; otherwise, nothing should
happen. What we need to do, then, is to check the position of the cursor when it is
over the panorama.
Since the panorama will be moving, we'll use an onEnterFrame handler to describe its
behavior. Enter the lines shown below. The function simply says that for each frame, we
should checkTheMouse . What we need to do next is to define what we mean by that.
7
8
9
10
11
12
// define the panorama actions
pano_mc.onEnterFrame = function()
{
checkTheMouse();
}
Search WWH ::




Custom Search