# Onrollover in for loop issue

**URL:** https://forum.kirupa.com/t/onrollover-in-for-loop-issue/328652
**Category:** Uncategorized
**Created:** [June 3, 2012, 10:20am UTC](https://forum.kirupa.com/t/onrollover-in-for-loop-issue/328652 "2012-06-03T10:20:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Harmeet\_Singh](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Harmeet\_Singh](https://forum.kirupa.com/u/Harmeet_Singh)
#### Post date: [June 3, 2012, 10:20am UTC](https://forum.kirupa.com/t/onrollover-in-for-loop-issue/328652/1 "2012-06-03T10:20:28Z")

</div>

```auto

var sname0 = "State1"; //but1
var sname1 = "State2"; //but2
var temp=0;

for (temp=0; temp<=10; temp++) {

	this['but'+temp].onRollOver = function (){
			
			trace('but'+temp); // this returns but11 
			bubble_mc._visible = true;
			bubble_mc.text = this['sname'+temp];
		}
		
	this['but'+temp].onRollOut = function (){
			bubble_mc.text = "";
			bubble_mc._visible = false;
		}	
}

```

The bubble\_mc.text comes out to be undefined. Also the trace(‘but’+temp) is returning but11 on hover. I am doing something wrong here as i have been out of practice for sometime. Please help.
