Is there a way to generalize an id for an onEvent?

Is there a way to generalize an id for an onEvent?

Say I have 3 buttons, named button1, button2, and button3, and they are all doing something similar.
Is there a way I could do something like indicate the button number somewhere else and then do an onEvent like:
onEvent (“button”+num, …)

where var num contains a number 1, 2, or 3

The idea is to try and avoid having 30 onEvents instructions if they are all doing the pretty much the same thing.

Right now, I think the answer is no, but maybe someone else has an idea.

Hi @dlarkin,

Recently another teacher created an example of using a for-loop to generate multiple buttons with associated events: Link to project

(Here’s the original forum post.)

So I think the answer to your question is “Yes, that’s possible”. However, I’m not sure what are your other requirements of these buttons and events, but hopefully your needs can be filled using a similar for-loop.

Does that help?

Frank