Graphics Programs Reference
In-Depth Information
24
25
26
27
28
29
30
31
32
33
34
35
36
37
scaleFactor = bigMap_mc._width / smallMap_mc._width;
bottom = smallMap_mc._y;
left = smallMap_mc._x;
top = smallMap_mc._y - smallMap_mc._height;
right = smallMap_mc._x + smallMap_mc._width;
magGlass_mc.handle.onPress = function() {
magGlass_mc.startDrag(false, left, top, right, bottom);
}
magGlass_mc.handle.onRelease = function() {
magGlass_mc.stopDrag();
}
The variable scaleFactor establishes the percentage of scale between the large and
small map. By dividing the width of the larger map by the smaller map's width, you get
the scale factor. Lines 26 through 29 define the bounding box of the smaller map and
store that information into four variables. With that information, the magnifying glass
can be restricted to this area (Lines 31 through 33).
68
69
70
71
72
73
74
75
76
77
bigMap_mc.onEnterFrame = function() {
mask_mc._x = magGlass_mc._x;
mask_mc._y = magGlass_mc._y;
dx = mask_mc._x - startX;
dy = mask_mc._y - startY;
bigMap_mc._x = bigMapStartX - (scaleFactor - 1) * dx;
bigMap_mc._y = bigMapStartY - (scaleFactor - 1) * dy;
Next we need to update the movie clips as the magnifying glass is being dragged. Using
the onEnterFrame function for bigMap_mc will accomplish this. Every time the playback
head enters the frame, the location of the mask shape is reset to the new location of
the magnifying glass. The big map also resets its position based on the scale factor and
the amount of distance the magnifying glass has moved.
The remaining code sets the navigation for each button when clicked on.
Search WWH ::




Custom Search