# For loop help please

**URL:** <https://forum.kirupa.com/t/for-loop-help-please/179213>\
**Category:** flash\
**Created:** [February 17, 2006, 5:51pm UTC](https://forum.kirupa.com/t/for-loop-help-please/179213 "2006-02-17T17:51:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![julzmon](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@julzmon](https://forum.kirupa.com/u/julzmon)\
**Post date:** [February 17, 2006, 5:51pm UTC](https://forum.kirupa.com/t/for-loop-help-please/179213/1 "2006-02-17T17:51:47Z")

</div>

```auto
for (i=1; i<21; i++) {
	portfolio_btns["pover_btn"+i].onRollOver = function() {
		this.alphaTo(overAlphaTo, overSpeed);
	};
	portfolio_btns["pover_btn"+i].onRollOut = function() {
		this.alphaTo(0, overSpeed);
	};
	portfolio_btns["pover_btn"+i].onPress = function() {
		var tweenTo = this._y+portfolio_btns._y;
		_parent.sq2_mc.tween("_y", tweenTo, 1);
		this.gotoAndPlay(i);
		trace(i);
	};
}

```

Can someone please help me figure this out.  
I’m trying to set the corresponding # inside “this.gotoAndPlay()”. So button one will gotoAndPlay 1 and button 2 play 2 and so on.

Thanks in advance.
