button symbol to make mcs visible one by one

Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Hi.

I have four movieclips sb1, sb2, sb3, sb4.

They all start off visible=false.

When I run my code upon clicking the btn it doesn't work.

I would appreciate any help.

Cheers.

Basically it's a sentence that I reveal word for word.

My    dog      is      driving.

this.sb1.visible =false;
this.sb2.visible =false;
this.sb3.visible =false;
this.sb4.visible =false;


btn_integer = 0;


this.btn.addEventListener("click", clickHandler.bind(this));

function clickHandler(event) 
{
  btn_integer = btn_integer + 1;
	If (btn_integer = 1) 
	{
		this.sb1.visible = true;
	} 
	If (btn_integer = 2)  
	{
		this.sb2.visible=true;
	}
	If (btn_integer = 3)  
	{
		this.sb3.visible=true;
	}
	If (btn_integer = 4)  
	{
		this.sb4.visible=true;
	}
}

 

Views

42

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 25, 2021 Feb 25, 2021
Hi.   There are 2 errors:   - The if  keyword must be in lowercase (if); - And you're using assignment operators (=) instead of equality operators (==).   Also, use else if to make your code more efficient.   It should be like this:       this.sb1.visible = false; this.sb2.visible = false; this.sb3.visible = false; this.sb4.visible = false; btn_integer = 0; // you're declaring a global variable here. Is this what you really want? If not, use the var keyword. E.g.: var btn_integer = 0; this.btn...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Hi.

 

There are 2 errors:

 

- The if  keyword must be in lowercase (if);

- And you're using assignment operators (=) instead of equality operators (==).

 

Also, use else if to make your code more efficient.

 

It should be like this:

 

 

 

this.sb1.visible = false;
this.sb2.visible = false;
this.sb3.visible = false;
this.sb4.visible = false;

btn_integer = 0; // you're declaring a global variable here. Is this what you really want? If not, use the var keyword. E.g.: var btn_integer = 0;

this.btn.addEventListener("click", clickHandler.bind(this));

function clickHandler(event) 
{
	btn_integer = btn_integer + 1;
		
	if (btn_integer == 1) 
	{
		this.sb1.visible = true;
	} 
	else if (btn_integer == 2)  
	{
		this.sb2.visible = true;
	}
	else if (btn_integer == 3)  
	{
		this.sb3.visible = true;
	}
	else if (btn_integer == 4)  
	{
		this.sb4.visible = true;
	}
}

 

 

 

 

Regards,

JC

Likes

translate

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
community guidelines
Explorer ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

THANK YOU so much.

I haven't written code for so many years and it's different in javascript but yes, I forgot the lowercase in the if statements and the == operator etc...

BUT I did change my code to else if, HOWEVER, I couldn't EDIT my post. Where is the edit button?

Likes

translate

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
community guidelines