Hey kirupa people
The following code (applied to a movieclip) let’s you scale (‘zoom’) the _root of the stage on mouseDown:
onClipEvent (load) {
var dir;
var pt;
var zoom;
k = 0;
}
onClipEvent (mouseDown) {
if(this.hitTest(_root._xmouse, _root._ymouse, true)){
if (k>0) {
return;
}
zoom = true;
dir == 1 ? (dir=-1) : (dir=1);
if (dir == 1) {
pt = {x:_root._xmouse, y:_root._ymouse};
}
}
}
onClipEvent (enterFrame) {
if (!zoom) {
return;
}
_root._xscale += dir*k*50/8;
_root._yscale += dir*k*50/8;
var pt2 = {x:pt.x, y:pt.y};
_root.localToGlobal(pt2);
_root._x -= (pt2.x-pt.x);
_root._y -= (pt2.y-pt.y);
k++;
if (k == 7) { // how close
zoom = false;
k = 0;
}
}
Although the code may be a little ugly, it works :hugegrin:
So far I’m able to zoom in on a certain point on mouseDown, and again zoom out to the original point on mouseDown.
BUT, I need a ‘little’ help with the next step:
What I would like to do is, zoom in, and then be able to move the stage around with the mouse_x and mouse_y - so that when I move my mouse to the left, the stage (_root._x) moves to the right, etc…
Hope you understand what I’m saying…!? - any help would be nice