Making a button visible on a array
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;
}
}
