Hey people
I have the following code:
// start
eAR = new Array();
eAR[0] = new Array(-2.7, -127.8);
eAR[1] = new Array(19.3, -121.4);
eAR[2] = new Array(14.2, -103.3);
eAR[3] = new Array(4.5, -105.1);
eAR[4] = new Array(1.2, -103.9);
eAR[5] = new Array(-8.2, -106.0);
// loop
for (p = 0; p < 3; p++) {
var myMC = _root.zmap.buttons.createEmptyMovieClip("luke" + p, 100 + p);
myMC.lineStyle(1,0x000000,100);
myMC.beginFill(0xff9900);
for (j = 0; j < (eAR.length + 1); j++) {
if (j == 0) {
myMC.moveTo(eAR[0][0] + (p * 50),eAR[0][1] + (p * 50));
} else if (j == eAR.length) {
myMC.lineTo(eAR[0][0] + (p * 50),eAR[0][1] + (p * 50));
} else {
myMC.lineTo(eAR[j][0] + (p * 50),eAR[j][1] + (p * 50));
}
myMC._alpha = 50;
}
myMC.endFill();
myMC.onPress = function() {
trace("you clicked me, i'm number " + p);
};
}
Pretty simple, all it’s doing is generating 3 shapes within their own mc, based on the co-ordinates from the array.
But I want to be able to individually control them. I currently have the “myMC.onPress…” function, but it’s not working. Clicking on any of them outputs “you clicked me, i’m number 3”. (even though the array should stop at 2. I figure that’s just overflow).
So I presume each function is being overwritten each time a new mc is made. So, what’s a better way to go about this?
Thanks a lot for your time
Luke :]