# HELP! AS2 \[Flash 8\] x & y pan

**URL:** https://forum.kirupa.com/t/help-as2-flash-8-x-y-pan/240439
**Category:** flash
**Created:** [October 2, 2007, 11:55pm UTC](https://forum.kirupa.com/t/help-as2-flash-8-x-y-pan/240439 "2007-10-02T23:55:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![zer05um](https://avatars.discourse-cdn.com/v4/letter/z/eb8c5e/32.png) [@zer05um](https://forum.kirupa.com/u/zer05um)
#### Post date: [October 2, 2007, 11:55pm UTC](https://forum.kirupa.com/t/help-as2-flash-8-x-y-pan/240439/1 "2007-10-02T23:55:22Z")

</div>

OK, I’ve followed the tutorial [[kirupa.com - Interactive Image Panning, Page 1](http://www.kirupa.com/forum/../developer/flash8/interactive_image_pan.htm)], and I’ve kinda got the x-pan working, but it does overshoot the image for some reason.

I even managed to get the y-pan to work too, but it still overshoots.

Here’s my adaption of the code:

this.onMouseMove = function()  
{  
constrainedMove(bg\_mc, 4, 1, 4, 1);  
};  
function constrainedMove(target:MovieClip, xspeed:Number, yspeed:Number) {

var mousePercent\_x:Number = ((\_xmouse/Stage.width));  
var mousePercent\_y:Number = ((\_ymouse/Stage.height));  
var mSpeed\_x:Number = 1-mousePercent\_x;  
var mSpeed\_y:Number = 1-mousePercent\_y;

target.destX = Math.round(-((target.\_width-Stage.width)\*mSpeed\_x));  
target.destY = Math.round(-((target.\_height-Stage.height)\*mSpeed\_y));

target.onEnterFrame = function() {  
if (target.\_x == target.destX)  
{  
delete target.onEnterFrame;  
}  
else  
{  
target.\_x += Math.ceil((target.destX-target.\_x)_(xspeed/100));  
}  
if (target.\_y == target.destY)  
{  
delete target.onEnterFrame;  
}  
else  
{  
target.\_y += Math.ceil((target.destY-target.\_y)_(xspeed/100));  
}  
};  
}

Otherwise, it’s set up as in the tutorial.

See [http://img214.imageshack.us/my.php?image=pan1sd6.swf](http://img214.imageshack.us/my.php?image=pan1sd6.swf) for the result.
