# Error when using array and loop

**URL:** <https://forum.kirupa.com/t/error-when-using-array-and-loop/286709>\
**Category:** flash\
**Created:** [April 20, 2009, 4:12am UTC](https://forum.kirupa.com/t/error-when-using-array-and-loop/286709 "2009-04-20T04:12:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bong3](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@bong3](https://forum.kirupa.com/u/bong3)\
**Post date:** [April 20, 2009, 4:12am UTC](https://forum.kirupa.com/t/error-when-using-array-and-loop/286709/1 "2009-04-20T04:12:39Z")

</div>

Anyone see anything wrong with this code? I have a set of 15 buttons on my stage. Trying to use an array with loop to quickly populate a new array with the instance names of my buttons, then add eventlisteners to all of them quickly too. And yes, I do have the Handler functions written out too, but I didn’t include, because the error I’m getting is  
“TypeError: Error #1006: value is not a function”

and the error keeps pointing to each of of the eventListeners within my for loop. Its saying that each of those eventListeners is a value that is not a function. ? I don’t get it. Thanks in advance.

* * *

var btnList:Array = new Array();  
var numBtns:int = 15;

for (var i:Number = 0; i \< numBtns; i++)  
{  
var btnName:String = “btn” + (i+1) + “\_mc”;  
btnList.push(btnName);  
}

for (var j:Number = 0; j \< btnList.length; j++)  
{  
btnList[j].addEventListener(MouseEvent.ROLL\_OVER, btnOver);  
btnList[j].addEventListener(MouseEvent.ROLL\_OUT, btnOut);  
btnList[j].addEventListener(MouseEvent.MOUSE\_DOWN, btnClick);  
btnList[j].buttonMode = true;  
}
