# Zooming via static crosshairs

**URL:** <https://forum.kirupa.com/t/zooming-via-static-crosshairs/233177>\
**Category:** Uncategorized\
**Created:** [July 20, 2007, 7:47pm UTC](https://forum.kirupa.com/t/zooming-via-static-crosshairs/233177 "2007-07-20T19:47:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lariat1997](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lariat1997](https://forum.kirupa.com/u/lariat1997)\
**Post date:** [July 20, 2007, 7:47pm UTC](https://forum.kirupa.com/t/zooming-via-static-crosshairs/233177/1 "2007-07-20T19:47:43Z")

</div>

Hey all,

I have a large mc masked by a small mc. Inside of the smaller mc, there is a static crosshair in the middle of the smaller mc. I can pan the larger mc fine, but would like to zoom in on the larger mc where ever the crosshairs are located.

[AS]  
//boundary limits for movement of image on stage  
var LBOUND:Number = -280;  
var TBOUND:Number = -160;  
var RBOUND:Number = 310;  
var BBOUND:Number = 500;  
var ZoomInBOUND:Number = 200;  
var ZoomOutBOUND:Number = 100;  
var INCR:Number = 10;  
var LBOUND\_INCR:Number = -(INCR/100\*((RBOUND-LBOUND)));  
var RBOUND\_INCR:Number = 0;  
var TBOUND\_INCR:Number = -(INCR/100\*((BBOUND-TBOUND)/2));  
var BBOUND\_INCR:Number = INCR/100\*((BBOUND-TBOUND)/2);  
stop();

image.\_xscale = 100;  
image.\_yscale = 100;  
// code to allow user to scroll around image using arrows, plus and minus key  
onEnterFrame = function () {  
if ((Key.isDown(Key.RIGHT))) {  
if (image.\_x\>(LBOUND+INCR)) {  
image.\_x -= INCR;  
} else if (image.\_x\<=(LBOUND+INCR)) {  
image.\_x = LBOUND;  
}  
}  
if (Key.isDown(Key.DOWN)) {  
if (image.\_y\>(TBOUND+INCR)) {  
image.\_y -= INCR;  
} else if (image.\_y\<=(TBOUND+INCR)) {  
image.\_y = TBOUND;  
}  
}  
if (Key.isDown(Key.LEFT)) {  
if (image.\_x\<(RBOUND-INCR)) {  
image.\_x += INCR;  
} else if (image.\_x\>=(RBOUND-INCR)) {  
image.\_x = RBOUND;  
}  
}  
if (Key.isDown(Key.UP)) {  
if (image.\_y\<(BBOUND-INCR)) {  
image.\_y += INCR;  
} else if (image.\_y\>=(BBOUND-INCR)) {  
image.\_y = BBOUND;  
}  
}  
if ((Key.isDown(107))) {  
//107 is the plus key on the number pad  
if ((image.\_xscale\<=(ZoomInBOUND-INCR)) and (image.\_yscale\<=(ZoomInBOUND-INCR))) {  
image.\_xscale += INCR;  
image.\_yscale += INCR;  
LBOUND = LBOUND\_INCR+LBOUND;  
RBOUND = RBOUND\_INCR+RBOUND;  
TBOUND = TBOUND\_INCR+TBOUND;  
BBOUND = BBOUND\_INCR+BBOUND;  
} else if ((image.\_xscale\<ZoomInBOUND) and (image.\_yscale\<ZoomInBOUND)) {  
LBOUND = (((ZoomInBOUND-image.\_xscale)/INCR)\*LBOUND\_INCR)+LBOUND;  
RBOUND = (((ZoomInBOUND-image.\_xscale)/INCR)\*RBOUND\_INCR)+RBOUND;  
TBOUND = (((ZoomInBOUND-image.\_xscale)/INCR)\*TBOUND\_INCR)+TBOUND;  
BBOUND = (((ZoomInBOUND-image.\_xscale)/INCR)\*BBOUND\_INCR)+BBOUND;  
image.\_xscale = ZoomInBOUND;  
image.\_yscale = ZoomInBOUND;  
}  
}  
if ((Key.isDown(109))) {  
//109 is the minus key on the number pad  
if ((image.\_xscale\>=(ZoomOutBOUND+INCR)) and (image.\_yscale\>=(ZoomOutBOUND+INCR))) {  
image.\_xscale -= INCR;  
image.\_yscale -= INCR;  
LBOUND = LBOUND-LBOUND\_INCR;  
RBOUND = RBOUND-RBOUND\_INCR;  
TBOUND = TBOUND-TBOUND\_INCR;  
BBOUND = BBOUND-BBOUND\_INCR;  
if (image.\_x\<LBOUND) {  
image.\_x = LBOUND;  
} else if (image.\_x\>RBOUND) {  
image.\_x = RBOUND;  
}  
if (image.\_y\<TBOUND) {  
image.\_y = TBOUND;  
} else if (image.\_y\>BBOUND) {  
image.\_y = BBOUND;  
}  
} else if ((image.\_xscale\>ZoomOutBOUND) and (image.\_yscale\>ZoomOutBOUND)) {  
LBOUND = LBOUND-(((image.\_xscale-ZoomOutBOUND)/INCR)\*LBOUND\_INCR);  
RBOUND = RBOUND-(((image.\_xscale-ZoomOutBOUND)/INCR)\*RBOUND\_INCR);  
TBOUND = TBOUND-(((image.\_xscale-ZoomOutBOUND)/INCR)\*TBOUND\_INCR);  
BBOUND = BBOUND-(((image.\_xscale-ZoomOutBOUND)/INCR)\*BBOUND\_INCR);  
image.\_xscale = ZoomOutBOUND;  
image.\_yscale = ZoomOutBOUND;  
if (image.\_x\<LBOUND) {  
image.\_x = LBOUND;  
} else if (image.\_x\>RBOUND) {  
image.\_x = RBOUND;  
}  
if (image.\_y\<TBOUND) {  
image.\_y = TBOUND;  
} else if (image.\_y\>BBOUND) {  
image.\_y = BBOUND;  
}  
}  
}  
};  
[/AS]
