# Restricting cursor area in Interactive Image Pan

**URL:** https://forum.kirupa.com/t/restricting-cursor-area-in-interactive-image-pan/283449
**Category:** flash
**Created:** [March 6, 2009, 10:14am UTC](https://forum.kirupa.com/t/restricting-cursor-area-in-interactive-image-pan/283449 "2009-03-06T10:14:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ransom1337](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@Ransom1337](https://forum.kirupa.com/u/Ransom1337)
#### Post date: [March 6, 2009, 10:14am UTC](https://forum.kirupa.com/t/restricting-cursor-area-in-interactive-image-pan/283449/1 "2009-03-06T10:14:17Z")

</div>

Hello,

I am using the Interactive Image Pan tutorial from this site, and it’s working fine. My problem is that my final .swf is embedded onto an html page and stretches for the entire width of the users screen. This means that if they have a particularly high resolution, the width of the .swf file stretches significantly beyond the initial stage settings. I’m okay with this, as I really need the .swf to fill the width of the screen.

However, it means that the cursor is able to be pointed more than 100% left or right of the stage, causing the panning image to move further left or right than it should.

What I need to know is how to get around this. I’m assuming I could set a boundary at the left and right of the stage where the code wouldn’t be active? My problem is that I don’t know how to do this, or even if it’s the best way.

Any help with this is appreciated.

Here’s my code:

```auto
this.onMouseMove = function() {
 constrainedMove(bg_mc, 4, 1);
 constrainedMove(fg_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 if (target._x>target.destX) {
   target._x -= Math.ceil((target._x-target.destX)*(speed/100));
  } else if (target._x<target.destX) {
   target._x += Math.ceil((target.destX-target._x)*(speed/100));
  }
 };
}

```

Thank you!
