Hi!
I’m not a very good programmer, but i’m trying to make a point and click game for the fun of it. Now I’m very stuck, and i need some help.
I’m having troubble with the .onPress function. I’ve made an array of movieclips, and i want to go through them in a loop, and make an onPress function for each of them. What im trying to do with the code below is to make the debugText tell me what movieclip i pressed:
var letterArray = new Array();
letterArray = [l1_mc, l2_mc, l3_mc, l4_mc, l5_mc, l6_mc, l7_mc, l8_mc, l9_mc,
l10_mc, l11_mc, l12_mc, l13_mc, l14_mc, l15_mc, l16_mc, l17_mc, l18_mc,
l19_mc, l20_mc, l21_mc, l22_mc, l23_mc, l24_mc, l25_mc, l26_mc, l27_mc,
l28_mc, l29_mc, l30_mc, l31_mc, l32_mc, l33_mc, l34_mc, l35_mc, l36_mc];
debugText=“Pressed movieclip nr:”;
for(var l=1; l<37; l++){
letterArray[l].gotoAndStop(l+1);
letterArray[l].onPress=function(){
debugText=debugText+ " "+l;
}
}
debugText outputs:
Pressed movieclip nr: 36 36 36 36 36 36
No matter what clip i press, i get the same output: 36.
why?
what can i do about it?
Thanks in advance!