Answered
clone a function that increment the object instance name
I want to clone a function that increment the object instance name:
var _this = this;
_this.rouge1.visible = false;
_this.BT1.on('mousedown', function () {
if (_this.rouge1.visible == false) {
_this.rouge1.visible = true;
} else {
_this.rouge1.visible = false;
}
});
_this.rouge2.visible = false;
_this.BT2.on('mousedown', function () {
if (_this.rouge2.visible == false) {
_this.rouge2.visible = true;
} else {
_this.rouge2.visible = false;
}
});
so as to have un new function with object name BT3, BT4, BT5.... and rouge3, rouge4, rouge5....
_this.rouge3.visible = false;
_this.BT3.on('mousedown', function () {
if (_this.rouge3.visible == false) {
_this.rouge3.visible = true;
} else {
_this.rouge3.visible = false;
}
});
......
without duplicating the code by hand
how to do ? Thanks for your help
