Several buttons and dynamic(?) EventListener
Hi everyone,
I place 10 buttons on my stage, name it "b1", "b2", "b3",.. , "b10".
All these buttons should use the same function.
Is it possible to do it dynamically?
var a: Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (var i = 0; i < a.length; i++) {
button = "b" + a;
this[button].addEventListener(MouseEvent.CLICK, onClick_b);
function onClick_b(pEvt: Event): void {
my_mc.play();
}
}
Only the button "b10" plays the function.
Anyone an idea how to let all the other buttons play this function?
Thank you! C.