How to pass loop value as argument in click event

Hi!

One of these days someone helped me about how to pass external arguments to timed events this way:

this.value1 = "foo";
this.value2 = "bar";
this.mytimedevent = this.time.addEvent({
   delay: 1000,
   callback: DoSomething,
   args:[this.value1,this.value2],
   callbackScope: this,
   repeat: 0
});

Now I would like to know how to do this for click events, passing the loop control var value as argument (something similar to this):

for (var a=1;a<=3;a++) {
   this["btnAnswer"+a].on('pointerup', (e) => {
      this.DoSomething(a);
   });
}

Any clue???

Thanks!

Short of memory? :slight_smile:

1 Like

Oh boy. Normally I write down all those details and I looked for in my notes and couldn’t find. My bad. I am so sorry. :roll_eyes:

PS: And thanks!