0

I have to do this code 103 times, but I can't create a function so I don't have to write it for each of the buttons (working with animate-cc + createjs).

this.Box1.addEventListener("click", click1.bind(this));

function click1() {
    this.parent.nombres.gotoAndStop(1);
}

this.Box2.addEventListener("click", click2.bind(this));

function click2() {
    this.parent.nombres.gotoAndStop(2);
}

this.Box3.addEventListener("click", click3.bind(this));

function click3() {
    this.parent.nombres.gotoAndStop(3);
}

I appreciate your help in advance.

jepeca
  • 1
  • 2

1 Answers1

0

You can put that in an array and then put it in a for or while loop.

I had the same problem. My scripting is to rusty so I do not know how to write the script exactly.

var buttons:Array = new Array(bnt1,bnt2,bnt3,bnt4,bnt5);

But even that can be simplefied.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
V-Jake
  • 1
  • 1