# Image Panning on load

**URL:** <https://forum.kirupa.com/t/image-panning-on-load/237452>\
**Category:** flash\
**Created:** [August 30, 2007, 2:02pm UTC](https://forum.kirupa.com/t/image-panning-on-load/237452 "2007-08-30T14:02:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BilboBoggins](https://avatars.discourse-cdn.com/v4/letter/b/8baadc/32.png) [@BilboBoggins](https://forum.kirupa.com/u/BilboBoggins)\
**Post date:** [August 30, 2007, 2:02pm UTC](https://forum.kirupa.com/t/image-panning-on-load/237452/1 "2007-08-30T14:02:55Z")

</div>

Hi

Ive created a new flash movie that pans an image when you move the mouse over it.

The problem I have is that I would like the movie to pan from right to left when the flash movie loads then pan in any direction when the mouse moves over it.

How would I modify the following code to do that?

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 == 1) {  
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));  
}  
};  
}

Many Thanks

Bilbo  
:puzzle:
