# Controlling an image pan with an array of objects?

**URL:** <https://forum.kirupa.com/t/controlling-an-image-pan-with-an-array-of-objects/200949>\
**Category:** flash\
**Created:** [September 16, 2006, 11:23pm UTC](https://forum.kirupa.com/t/controlling-an-image-pan-with-an-array-of-objects/200949 "2006-09-16T23:23:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![REEF](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@REEF](https://forum.kirupa.com/u/REEF)\
**Post date:** [September 16, 2006, 11:23pm UTC](https://forum.kirupa.com/t/controlling-an-image-pan-with-an-array-of-objects/200949/1 "2006-09-16T23:23:41Z")

</div>

Heres the image pan code I’m using, thanks to Krilnon:

```auto

MovieClip.prototype.setDest = function(speed:Number):Void {
    this.mousePercent = _xmouse/Stage.width;
    this.destX = Math.round(-((this._width-Stage.width)*this.mousePercent));
    this.onEnterFrame = function():Void {
        (this._x == this.destX) ? delete this.onEnterFrame : this._x += Math.ceil((this.destX-this._x)*(speed/100));
    };
};
onMouseMove = function ():Void {
   bg_mc.setDest(5);
};

```

This code controls bg\_mc only, I was wondering if it would be possible to control btn0 all the way to btn22 for this code? I want bt0~btn22 to be controlled as one object. Ive tried pushing them into an array & using that but that didnt work too well.

Heres what I tried:

```auto
allMCs = [];
MovieClip.prototype.setDest = function(speed:Number):Void {
	this.mousePercent = _xmouse / Stage.width;
	this.destX = Math.round(-((this._width - Stage.width) * this.mousePercent));
	this.onEnterFrame = function():Void {
		(this._x == this.destX) ? delete this.onEnterFrame : this._x += Math.ceil((this.destX - this._x) * (speed / 100));
	};
};
onMouseMove = function ():Void {
	for (i = 0; i <= 22; i++) {
		allMCs* = ["btn" + i];
		allMCs.setDest(5);
		trace(allMCs);
	}
};

```

Thanks.
