Copy link to clipboard
Copied
I want to make an array of buttons, and depending on what button was clicked, to sned and variable to the function and make stuff appear visible or invisible. I dont know how to say but heres the code:
var ClickCount = 0;
var BG_Aberto = false;
var Item1_Coletado = false;
var BTN_Coletar = [this.BTN_Coletar_Item1];
var BTN_Devolver = [this.BTN_Devolver_Item1];
var BTN_Item = [this.Item1];
var BG_Item = [this.BG_Item1];
var Item_Coletado = [this.Item1_Coletado];
this.Item1.addEventListener("click", clicarItem(i).bind(this));
this.BTN_Coletar_Item1.visible = false;
this.BTN_Devolver_Item1.visible = false;
this.BG_Item1.visible = false;
function clicarItem(i)
{
ClickCount++;
if (this[BG_Item[i]].visible == false){
this[BG_Item[i]].visible = true;
if(Item_Coletado[i]==false){
this[BTN_Coletar[i]].visible = true;
this[BTN_Devolver[i]].visible = false;
} else {
this[BTN_Coletar[i]].visible = false;
this[BTN_Devolver[i]].visible = true;
}
} else {
BG_Aberto = false;
this[BG_Item[i]].visible = false;
this[BTN_Coletar[i]].visible = false;
this[BTN_Devolver[i]].visible = false;
}
}
I found the problem!
this.Item1.addEventListener("click", clicarItem(i).bind(this));
this is the problem. If anyone have the same problem you need to write like this:
this.Item1.addEventListener("click", clicarItem.bind(this, variable of the function*));
and this:
this.[BG_Item[i]].visible = true;
turn into this:
BG_Item[i].visible = true;
Copy link to clipboard
Copied
Hi,
In order for us to assist you, it might be better if you could explain what you are trying to achieve with your code.
Copy link to clipboard
Copied
that code has so many problems it almost certainly needs to be redone in its entirety.
Copy link to clipboard
Copied
I found the problem!
this.Item1.addEventListener("click", clicarItem(i).bind(this));
this is the problem. If anyone have the same problem you need to write like this:
this.Item1.addEventListener("click", clicarItem.bind(this, variable of the function*));
and this:
this.[BG_Item[i]].visible = true;
turn into this:
BG_Item[i].visible = true;