# URGENT---center image when draged and zoomed

**URL:** <https://forum.kirupa.com/t/urgent-center-image-when-draged-and-zoomed/194925>\
**Category:** flash\
**Created:** [July 27, 2006, 8:07am UTC](https://forum.kirupa.com/t/urgent-center-image-when-draged-and-zoomed/194925 "2006-07-27T08:07:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanshinde](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pavanshinde](https://forum.kirupa.com/u/pavanshinde)\
**Post date:** [July 27, 2006, 8:07am UTC](https://forum.kirupa.com/t/urgent-center-image-when-draged-and-zoomed/194925/1 "2006-07-27T08:07:23Z")

</div>

Hi All

I have created a flash which zooms a map with CTRL+click and zoom out with SHIFT+ click. When user double clicks on the map the map zooms and pan the map center to the point where user double clicked.

import mx.transitions.Tween;  
import mx.transitions.easing._;  
//===============================  
startHeight = 450;  
startWidth = 600;  
initMapx = map.\_x;  
initMapy = map.\_y;  
function zoom(amount) {  
trace(" Amount : "+amount);  
xoffset = startWidth_(map.\_x-startX)/(100/amount_map.\_width)-dragX;  
yoffset = startHeight_(map.\_y-startY)/(100/amount\*map.\_height)-dragY;  
trace(" xoffset : “+xoffset);  
trace(” yoffset : "+yoffset);  
map.\_xscale = map.\_xscale+amount;  
map.\_yscale = map.\_yscale+amount;  
endEaseX = initMapx+xoffset;  
endEaseY = initMapy+yoffset;  
x\_coord = map.\_x;  
y\_coord = map.\_y;  
trace(x\_coord);  
//auto paning  
if (\_global.drawValue == 1) {  
trace(“Inside If”);  
var xPosT:Tween = new Tween(map, “\_x”, Regular.easeIn, map.\_x, endEaseX, 1, true);  
var yPosT:Tween = new Tween(map, “\_y”, Regular.easeIn, map.\_y, endEaseY, 1, true);  
} else {  
trace(“Inside Else”);  
var xPosT:Tween = new Tween(map, “\_x”, Regular.easeIn, map.\_x, endEaseX, 1, true);  
var yPosT:Tween = new Tween(map, “\_y”, Regular.easeIn, map.\_y, endEaseY, 1, true);  
}

I have a button “DRAW”. When a user click on this button, then he/she be able to click and drag the mouse to select an area of the map to ZOOM.

My problem is that I want this area to be centered Like i have for double click.

PLZ help.

Thanks
