# AS: Looping an Array for .onRelease problem

**URL:** <https://forum.kirupa.com/t/as-looping-an-array-for-onrelease-problem/192407>\
**Category:** flash\
**Created:** [June 28, 2006, 12:08pm UTC](https://forum.kirupa.com/t/as-looping-an-array-for-onrelease-problem/192407 "2006-06-28T12:08:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![halian](https://avatars.discourse-cdn.com/v4/letter/h/45deac/32.png) [@halian](https://forum.kirupa.com/u/halian)\
**Post date:** [June 28, 2006, 12:08pm UTC](https://forum.kirupa.com/t/as-looping-an-array-for-onrelease-problem/192407/1 "2006-06-28T12:08:47Z")

</div>

hey everyone. I’m having a problem with some code and maybe you can help me out.  
I have two arrays. One is used for button names and the other is used for the links for the buttons. The buttons are generated dynamically with attachMovie and the names are also modified via AS. My problem comes in at looping through the links array and applying them to the buttons.

```auto
myText = ["First", "Second", "Third"];
myLinks = ["http://google.com", "http://yahoo.com", "http://aol.com"];
total = myText.length;
//<----------here is where the problem resides------------>//
for (i=0; i<total; i++) {
	_root.attachMovie("button", "button"+i, i, {_x:200, _y:50+(i*33)});
	_root["button"+i].text_txt.text = myText*;
	_root["button"+i].onRelease = function() {
		//<-------specifically the following line--------->//
		// it doesn't seem to loop through the i, however,
		// if i change "i" to a specific value in the array like "1"
		// it will produce "http://yahoo.com" as expected.
		// also, i'm using trace instead of getURL to save time.
		trace(myLinks*);
	};
}

```

thanks guys.
