# Function with for loop accessing array, whats the problem?

**URL:** <https://forum.kirupa.com/t/function-with-for-loop-accessing-array-whats-the-problem/200131>\
**Category:** flash\
**Created:** [September 8, 2006, 10:24pm UTC](https://forum.kirupa.com/t/function-with-for-loop-accessing-array-whats-the-problem/200131 "2006-09-08T22:24:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadBadNeil](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@BadBadNeil](https://forum.kirupa.com/u/BadBadNeil)\
**Post date:** [September 8, 2006, 10:24pm UTC](https://forum.kirupa.com/t/function-with-for-loop-accessing-array-whats-the-problem/200131/1 "2006-09-08T22:24:12Z")

</div>

Hello,  
Thanks first for any help. This must be something small that I am missing.

I have two arrays both stored with button names and clip names. I have a function that has a for loop that counts the amount in the array and then should place the names from the array into the spots to run the buttons. I can access the arrays with the trace command but the buttons won’t work. Any ideas?

Thanks!

```auto

myButtons = new Array("homeBtn", "aboutBtn");
myClips = new Array("homeClip", "aboutClip");

function myRollOver(){
	for(i=0; i<myButtons.length; i++){
		//trace(myButtons*);
		myButtons*.onRollOver = function() {
			myClips*.gotoAndPlay("on");
		}
	}
}
myRollOver();

```
