Graphics Programs Reference
In-Depth Information
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
setCursor = function () {
if (_xmouse < xStart - 5) { column = 1; }
else if (_xmouse > xStart + 5) { column = 3; }
else column = 2;
if (_ymouse < yStart - 5) { row = 1; }
else if (_ymouse > yStart + 5) { row = 3; }
else row = 2;
n = column + (row - 1) * 3;
cursor_mc.gotoAndStop(n);
}
rotateCompass = function() {
// determine how much the pano has moved horizontally
dx = pano_mc._x - lastx;
// calculate the rotation of the compass point
// note that maxX == 1 full rotation of the panorama
// we need a negative rotation value because
// of the direction of Flash rotation
compass_mc.pointer_mc._rotation -= dx * 360 / maxX;
// update the current horizontal location of the pano
currentx = pano_mc._x;
}
To rotate the pointer, the distance from the panorama's last position, lastx , to its cur-
rent position is set to dx . When the panorama moves a distance equal to maxX , the
point at which it has had one full rotation, then there should be an equivalent full 360-
degree rotation of the compass pointer. To convert the incremental distance dx to an
incremental rotation angle, a simple proportional relationship is used
dx/maxX = rotation angle/360
from which
rotation angle = dx*360/maxX
A negative value must be used for this rotation angle because of the direction of Flash
rotation. After the rotation is carried out, the panorama's current position is set to
lastx , and the process repeats whenever the panorama is moved.
Search WWH ::




Custom Search