Highlighted

Button

Explorer ,
Aug 20, 2020

Copy link to clipboard

Copied

In my slide show I have HTML5 canvas and there I have a button that changes an image but when you press the button
then nothing happens on the first press but the second press so it happens the image is displayed.
I want it to happen on the first print.
Here is the code:
this.button.addEventListener("click", Toggle3.bind(this));
var on = 0;
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;
function Toggle3() {
if (on == 0) {
this.nr60b_btn.visible = true;
this.nr60a_btn.visible = true;
this.stop();
on = 1;
} else {
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;
on = 0;
}
}

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

Hi.

 

It think this is a great opportunity to use the logical NOT (!) operator.

 

this.button.addEventListener("click", Toggle3.bind(this));
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;

function Toggle3()
{
	this.nr60b_btn.visible = !this.nr60b_btn.visible;
	this.nr60a_btn.visible = !this.nr60a_btn.visible;
	
	if (this.nr60b_btn.visible)
		this.stop();
}

 

 

Please let us know.

 

Regards,

JC

TOPICS
How to, Other, Performance

Views

39

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

Button

Explorer ,
Aug 20, 2020

Copy link to clipboard

Copied

In my slide show I have HTML5 canvas and there I have a button that changes an image but when you press the button
then nothing happens on the first press but the second press so it happens the image is displayed.
I want it to happen on the first print.
Here is the code:
this.button.addEventListener("click", Toggle3.bind(this));
var on = 0;
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;
function Toggle3() {
if (on == 0) {
this.nr60b_btn.visible = true;
this.nr60a_btn.visible = true;
this.stop();
on = 1;
} else {
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;
on = 0;
}
}

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

Hi.

 

It think this is a great opportunity to use the logical NOT (!) operator.

 

this.button.addEventListener("click", Toggle3.bind(this));
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;

function Toggle3()
{
	this.nr60b_btn.visible = !this.nr60b_btn.visible;
	this.nr60a_btn.visible = !this.nr60a_btn.visible;
	
	if (this.nr60b_btn.visible)
		this.stop();
}

 

 

Please let us know.

 

Regards,

JC

TOPICS
How to, Other, Performance

Views

40

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
Aug 20, 2020 0
Adobe Community Professional ,
Aug 20, 2020

Copy link to clipboard

Copied

Hi.

 

It think this is a great opportunity to use the logical NOT (!) operator.

 

this.button.addEventListener("click", Toggle3.bind(this));
this.nr60b_btn.visible = false;
this.nr60a_btn.visible = false;

function Toggle3()
{
	this.nr60b_btn.visible = !this.nr60b_btn.visible;
	this.nr60a_btn.visible = !this.nr60a_btn.visible;
	
	if (this.nr60b_btn.visible)
		this.stop();
}

 

 

Please let us know.

 

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...
Aug 20, 2020 0
peor LATEST
Explorer ,
Aug 20, 2020

Copy link to clipboard

Copied

Thank you so much for the help because this works with the code you gave works at once when I press the button instead of the second time with the previous code I had.

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...
Aug 20, 2020 0