I know how to write loops to make my variable code short and efficient, but is there some way to to the same with code for buttons?
I have a quiz with 50 buttons, and the code for the buttons is written in the first frame along with the rest of the script:
button1.onRelease = function() {
this._parent.answer(1);
};
button2.onRelease = function() {
this._parent.answer(2);
};
button3.onRelease = function() {
this._parent.answer(3);
};
//And so on until
button50.onRelease = function() {
this._parent.answer(50);
};
This takes up more lines than half of the whole script, and seems unnecessarily bulky.
If anyone has any thoughts on how to minimize the amount of code for this, I would be very thankful.