views:

124

answers:

1

ingredients:

- one vector map
- one masked viewing area
- one slider taking the map from 100% to 600%
- map is draggable
- map movieclip center is the top left of the movieclip

Let's say you zoom in, you drag the map so that the bottom right quadrant is in the viewing area, then you zoom out.

The problem: Because the "center" of the map is the top left corner of the movie clip, scaling happens from that point. How can I keep the center point (while scaling) as the point which is centered on the view area?

A: 

Right after you scale you map, you could reposition the map so it's center matches the masks center.

//assuming map is the name of your map clip, and mapMask the name of the mask
map.x = mapMask.x + mapMask.width * .5 - map.width * .5;
map.y = mapMask.y + mapMask.height * .5 - map.height * .5;

This should work as the mask will always be larger than the mask.

Goodluck!

George Profenza

related questions