# Enhancement to Image Panning Effect

**URL:** https://forum.kirupa.com/t/enhancement-to-image-panning-effect/233165
**Category:** flash
**Created:** [July 20, 2007, 6:21pm UTC](https://forum.kirupa.com/t/enhancement-to-image-panning-effect/233165 "2007-07-20T18:21:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jomoweb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jomoweb/32/3910_2.png) [@jomoweb](https://forum.kirupa.com/u/jomoweb)
#### Post date: [July 20, 2007, 6:21pm UTC](https://forum.kirupa.com/t/enhancement-to-image-panning-effect/233165/1 "2007-07-20T18:21:44Z")

</div>

I recently took the “interactive image panning” tutorial: [http://www.kirupa.com/developer/flash8/interactive\_image\_pan.htm](http://www.kirupa.com/developer/flash8/interactive_image_pan.htm)

I would like to enhance this effect by having the image return to center after it is moused off of. Currently, it will just stay where you left off. It would be neat if it returned at the same speed as it pans. I would love to see if this can be done for a client. Here is the code from the tutorial:

```auto

this.onMouseMove = function() { 
constrainedMove(bg_mc, 4, 1); 
}; 
function constrainedMove(target:MovieClip, speed:Number, dir:Number) { 
var mousePercent:Number = _xmouse/Stage.width; 
var mSpeed:Number; 
if (dir == 0) { 
mSpeed = 1-mousePercent; 
} else { 
mSpeed = mousePercent; 
} 
target.destX = Math.round(-((target._width-Stage.width)*mSpeed)); 
target.onEnterFrame = function() { 
if (target._x == target.destX) { 
delete target.onEnterFrame; 
} else { 
target._x += Math.ceil((target.destX-target._x)*(speed/100)); 
} 
}; 
}  

```
