Graphics Programs Reference
In-Depth Information
Step 13: Directional movements of the mouse
We are soon going to define a setCursor handler, which will select a cursor based on
the directional movements of the mouse. Referring to Figure 8.17, we will assume that
when a user presses the mouse button down, the nine general movements indicated
by the cursors are possible. The cursors are displayed in a matrix of rows and columns.
The relationship between any
cursor number n, and its row
and column values is given by
the expression
n = column + (row - 1) * 3
Figure 8.17 The relationship between the cursor number and its matrix location
When a user holds the mouse button down and moves the mouse, we will test to see
which column above describes the horizontal movement and which row describes the
vertical movement. The intersection of the correct row and column is the cursor that
needs to be used.
Step 14: Create the setCursor() handler
Using the expression above, we will relate the direction of the mouse movement to
the correct frame in the cursor_mc movie clip with the setCursor() handler. Place the
function shown below at the bottom of the other functions. Uncomment the setCursor()
line in the checkTheMouse handler.
78
79
80
81
82
83
setCursor = function ()
{
if (_xmouse < startX - 5) { column = 1;}
else if (_xmouse > startX + 5) { column = 3;}
else column = 2;
Search WWH ::




Custom Search