# Loops and array

**URL:** <https://forum.kirupa.com/t/loops-and-array/316577>\
**Category:** Uncategorized\
**Created:** [November 26, 2010, 5:08pm UTC](https://forum.kirupa.com/t/loops-and-array/316577 "2010-11-26T17:08:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonassus](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bonassus](https://forum.kirupa.com/u/bonassus)\
**Post date:** [November 26, 2010, 5:08pm UTC](https://forum.kirupa.com/t/loops-and-array/316577/1 "2010-11-26T17:08:12Z")

</div>

I have posted a similar question before but no one has answered it. If you don’t know the answer or don’t understand the question please don’t respond. These may seem like weird questions but it would be helpful to get an answer.

I want to call the functions with a loop with out putting them in an array. Is this possible. when I try the code below I get the error:  
Type Coercion failed: cannot convert “onFunction4” to Function.

```auto
btnArray:Array = new Array(btn1,btn2,btn3,btn4,);

for(i = 0; i < 5; i++){
btnArray*.addEventListener(MouseEvent.CLICK, "onFunction" +i);
}

onFunction1(){
//do something
}
onFunction2(){
//do something
}
onFunction3(){
//do something
}
onFunction4(){
//do something
}

```

Q:Is there a way to declare these as a function?

Q:Is it possible to call these functions by concatenating “onFunction” with i ?

Q:Is there another way to do this?

Thank you.
