Graphics Programs Reference
In-Depth Information
Exercise 8.4: Panning and Scrolling in Flash
In this exercise, you will set up a simple navigational interface that will more accurately
simulate a QTVR panorama in Flash by enabling the user to do a continuous pan and a
limited scroll of a panorama image. The user controls the movement of the background
by dragging the cursor in any direction on the Stage. Cursors will change according to
the direction of the drag movement.
Step 1: Getting started
Open the file 8_4_pano.fla in the Chapter 8 folder. The file is a duplicate of the com-
pleted version of the previous exercise. Although the movie works perfectly well just by
passing the cursor over the background, some users feel uncomfortable with this and
prefer to have the panning occur by pressing the mouse button down. This is, in fact,
the way a QTVR panorama actually functions. Let's modify our movie to pan the back-
ground in the same fashion as a QTVR by panning only when the mouse button is down.
Step 2: Define a pressed variable
Let's define a variable called pressed that will be initially set to false. When the user
presses down on the panorama, we will set pressed to true and hide the normal cursor.
When the user lets up on the mouse, we will set pressed back to false. Also, replace the
rollover and rollout handlers (which are no longer needed) with the lines below.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var xmin:Number = Stage.width-xmax; // min position of pano
var pressed:Boolean = false; // used for pressing mouse down
// define the panorama actions
pano_mc.onPress = function()
{
pressed = true;
Mouse.hide();
}
pano_mc.onRelease = pano_mc.onReleaseOutside = function()
{
pressed = false;
Mouse.show();
}
pano_mc.onEnterFrame = function()
 
Search WWH ::




Custom Search