Copy link to clipboard
Copied
Good morning, I'm doing an exercise and I want to use the conditional if, I did this code but it doesn't work for me, someone knows why it is.
Basically it is that when you click on an object it disappears and when all disappears that I display a message of retro feeding.
var _this = this;
_this.retro.visible = false;
_this.hit_fruta.on('click', function(){
_this.mc_fruta.visible = false;
_this.hit_fruta.visible = false;
SigEjer();
});
_this.hit_gato.on('click', function(){
_this.mc_pan.visible = false;
_this.hit_gato.visible = false;
SigEjer();
});
_this.hit_laptop.on('click', function(){
_this.mc_basura1.visible = false;
_this.hit_laptop.visible = false;
SigEjer();
});
_this.hit_consola.on('click', function(){
_this.mc_basura3.visible = false;
_this.hit_consola.visible = false;
SigEjer();
});
_this.hit_pelota.on('click', function(){
_this.mc_basura2.visible = false;
_this.hit_pelota.visible = false;
SigEjer();
});
_this.hit_paraguas.on('click', function(){
_this.mc_mesa.visible = false;
_this.hit_paraguas.visible = false;
SigEjer();
});
function SigEjer() {
if ( mc_mesa1._visible = false &&
mc_basura1._visible = false &&
mc_basura2._visible = false &&
mc_pan._visible = false &&
mc_fruta._visible = false &&
mc_basura3._visible = false
){
_this.retro.visible = true;
}
}
Hi.
Your code has at least three problems.
Inside of your SigEjer function body:
- You are referencing all objects in the if statement without _this (I suppose this is the correct context);
- There is no underscore in the visible property. It must be visible not _visible;
- You are using an assignment operator (=) in the if statement. You must use double equals (loose equality) or tripe equals (strict equality).
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Your code has at least three problems.
Inside of your SigEjer function body:
- You are referencing all objects in the if statement without _this (I suppose this is the correct context);
- There is no underscore in the visible property. It must be visible not _visible;
- You are using an assignment operator (=) in the if statement. You must use double equals (loose equality) or tripe equals (strict equality).
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Thank you very much, the advice worked for me.