# Vertical Panning

**URL:** <https://forum.kirupa.com/t/vertical-panning/319332>\
**Category:** flash\
**Created:** [February 16, 2011, 4:02pm UTC](https://forum.kirupa.com/t/vertical-panning/319332 "2011-02-16T16:02:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bladeswim83](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@bladeswim83](https://forum.kirupa.com/u/bladeswim83)\
**Post date:** [February 16, 2011, 4:02pm UTC](https://forum.kirupa.com/t/vertical-panning/319332/1 "2011-02-16T16:02:10Z")

</div>

Hello,

I’ve done the horizontal image panning tutorial on here and I was wondering what I need to change to make it vertical. Someone on here posted some code but it is in AS3 and I need it in AS2. 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 == 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 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));
		}
	};
}

```

I tried changing all the x’s to y’s but that allowed the image to go up and not back down. An help is MUCH appreciated! Thanks!!

Lindsae
