# Saving the value of 'i' in a for loop

**URL:** https://forum.kirupa.com/t/saving-the-value-of-i-in-a-for-loop/258636
**Category:** flash
**Created:** [April 25, 2008, 10:05pm UTC](https://forum.kirupa.com/t/saving-the-value-of-i-in-a-for-loop/258636 "2008-04-25T22:05:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![iomega\_zippy](https://avatars.discourse-cdn.com/v4/letter/i/5fc32e/32.png) [@iomega\_zippy](https://forum.kirupa.com/u/iomega_zippy)
#### Post date: [April 25, 2008, 10:05pm UTC](https://forum.kirupa.com/t/saving-the-value-of-i-in-a-for-loop/258636/1 "2008-04-25T22:05:56Z")

</div>

Is there a way to save the value of ‘i’ in a for loop for use later? In the example below it just always will give me the last value of ‘i’…

```auto
for(i=1; i<=5; i++) {
	trace(i);
	this["button" + i + "_mc"].onRollOver = function() {
		this._alpha = 100;
		[COLOR="Red"]var title:String = "Button Number " + i;[/COLOR]
		buttonTitle(this, true, title);
	}
	
	this["button" + i + "_mc"].onRollOut = function() {
		this._alpha = 80;
		buttonTitle(this, false);
	}
}

```
