Reputation: 379
In the first frame of the movie, I declared an array variable and create movieclips:
frame = new Array();
for(i=1; i<=5; i++){
frame[i] = "empty";
var a = attachMovie("box", "box"+i, i, {_x:i*100, _y:100});
}
I want to use the variable frame[] to count how many times the movieclips are clicked. I came to make a class for the movieclip "box" which I use, but couldn't figure out how to find out which button is clicked.
Upvotes: 0
Views: 294
Reputation: 936
Not even need to create a class for box, just pass index i as parameter to each movieclip in method attachMovie:
frame = new Array();
for(i=1; i<=5; i++){
frame[i] = "empty";
var a = attachMovie("box", "box"+i, i, {_x:i*100, _y:100, index:i});
a.onMouseDown = function ()
{
trace(this["index"])
}
}
After that each box knows its own index in frame array.
Upvotes: 1