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.
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.