01 June 2009

Maui Flash Zoom Tool

Previously made Flash Zoom Tool have several restrictions and one obvious is not-continuously zooming since you have only few scaling steps. Let's update that feature.

This time I'm using Maui island map by Mike Johnston. It will be even better and it is recommended to use vector maps instead of bitmaps, but this time that's not important.

Moving around the map is the same. Only new things are dragging functions and scaling. Here is entire code:


var rpoint = line._y - (line._height / 2); // reference point

onLoad = function() {
stool._x = line._x;
stool._y = line._y;
}

onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
map_mc._x -= 5;
}
else if (Key.isDown(Key.LEFT)) {
map_mc._x += 5;
}
else if (Key.isDown(Key.UP)) {
map_mc._y += 5;
}
else if (Key.isDown(Key.DOWN)) {
map_mc._y -= 5;
}
}

stool.onEnterFrame = function () {

// restrictions for stool mc movement

if (this._y < rpoint) {
this._y = rpoint;
}
if (this._y > (rpoint+line._height)) {
this._y = (rpoint+line._height);
}
this._x = line._x;

// scale amount

var ypos = Math.abs(stool._y-rpoint);
map_mc._xscale = map_mc._yscale = ypos*2 + 50;
}

stool.onPress = function () {
this.startDrag();
}
stool.onRelease = function () {
this.stopDrag();
}
stool.onDragOut = function () {
this.stopDrag();
}


ypos value range is between 0 and 50 and accordingly scaling is between 50 and 150. I'm using formula ypos*2+50 but you can use whatever numbers suits you. If you let's say use ypos*4+20 you will have scaling in range from 20 to 220 because :

ypos = 0 : ypos*4+20 = 0*4+20 = 20
ypos = 50 : ypos*4+20 = 50*4+20 = 220 etc.





*_*

2 comments:

Anonymous said...

Hi, this is a great tutorial, very simple and concise.
It is very helpful. I was trying for a while to find something like this and nothing but this!
By the way I tried to download the tool but it looks it is not available any more.

flanture said...

download link updated

 

template by blogger templates