BluesmanUK
Programmer
Hi there, I wonder if anyone can answer a question thats been bugging me for a while. All i want to do is create a bunch of buttons, each passing a unique id to a function when clicked. Something like this:
function createButtons() {
for (var i=0; i<buttonArray.length; i++) {
_root.attachMovie("button_mc", "button"+i, i);
// some code to position the buttons
_root["button"+i]._x = 0;
_root["button"+i]._y = (_root["button"+i]._height)*i;
_root["button"+i].onRelease = function() {
// here is where i get a bit confused
trace("button " + i + " was clicked");
}
// this doesnt work either
// _root["button"+i].onRelease = doClick(i);
}
}
im sure theres a really easy answer, Im probably not following best practice for actionscript coding , so any advice would be most welcome!
cheers,
James
function createButtons() {
for (var i=0; i<buttonArray.length; i++) {
_root.attachMovie("button_mc", "button"+i, i);
// some code to position the buttons
_root["button"+i]._x = 0;
_root["button"+i]._y = (_root["button"+i]._height)*i;
_root["button"+i].onRelease = function() {
// here is where i get a bit confused
trace("button " + i + " was clicked");
}
// this doesnt work either
// _root["button"+i].onRelease = doClick(i);
}
}
im sure theres a really easy answer, Im probably not following best practice for actionscript coding , so any advice would be most welcome!
cheers,
James