# For Loop Question

**URL:** <https://forum.kirupa.com/t/for-loop-question/219251>\
**Category:** flash\
**Created:** [March 15, 2007, 2:47am UTC](https://forum.kirupa.com/t/for-loop-question/219251 "2007-03-15T02:47:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lacohido](https://avatars.discourse-cdn.com/v4/letter/l/e8c25b/32.png) [@lacohido](https://forum.kirupa.com/u/lacohido)\
**Post date:** [March 15, 2007, 2:47am UTC](https://forum.kirupa.com/t/for-loop-question/219251/1 "2007-03-15T02:47:23Z")

</div>

Hi there-  
I using a for loop for a redundant action that I want to happen across 5 buttons. OnRollOver the button rotates. OnPress the button moves to a new position. It looks like this:

```auto

for(i=0;i<5;i++){
_root.swatch_mc['swatch'+i].onRollOver = function () {
	this.onEnterFrame = function () {
		this._rotation += (-2-this._rotation)/speed;
		}
	}
_root.swatch_mc['swatch'+i].onRollOut = function () {
	this.onEnterFrame = function () {
		this._rotation += (0-this._rotation)/speed;
		}
	}
_root.swatch_mc['swatch'+i].onPress = function () {
	var selected = this;
	this.enabled=false;
	selected.onEnterFrame = function () {
		this._y += (-100-this._y)/speed;
		}
		}
}

```

My problem is this; onPress I want the button to move up (Ive achieved this already). I also want the other buttons to move down onPress (this is my problem). Is there a way have the other 4 buttons move down onPress using the for loop? Or is there another method of doing this?

check out the example of what i have here [http://acohido.com/pantonetest.swf](http://acohido.com/pantonetest.swf)

Thanks!!
