Highlighted

Use of conditionals IF

New Here ,
Dec 10, 2019

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;

}

}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
Code, Error

Views

34

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Use of conditionals IF

New Here ,
Dec 10, 2019

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;

}

}

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
Code, Error

Views

35

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 10, 2019 1
Adobe Community Professional ,
Dec 10, 2019

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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 10, 2019 0
odeandar LATEST
New Here ,
Dec 10, 2019

Copy link to clipboard

Copied

Thank you very much, the advice worked for me.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 10, 2019 0