• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple buttons to visit webpage opens 1000 tabs

Community Beginner ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

Greetings, 

 

I would like some help in adobe animate , I create an animation with multiple buttons which each buttons visit different webpages. 

 

However, when I publish the project and click buttons open for me 1000 tab in browser for single tab. 

 

Could you please advice and help how to make sure it open in single click only once, every time press on the button. 

 

Looking forward to hear your solutions

 

 

Views

192

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

Community Expert , May 16, 2024 May 16, 2024

Hi.

 

Usually this happens when the same button receives multiple event listeners of the same type when a frame is revisited.

 

One approach I like to use is to check for a custom boolean flag. Like this:

if (!this.started)
{
    // code to add listeners
    this.started = true;
}

 

This ensures that the listeners are added only once.

 

But if you show us your code, we may be able to help you better.

 

Regards,

JC

Votes

Translate

Translate
Community Expert ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

Hi.

 

Usually this happens when the same button receives multiple event listeners of the same type when a frame is revisited.

 

One approach I like to use is to check for a custom boolean flag. Like this:

if (!this.started)
{
    // code to add listeners
    this.started = true;
}

 

This ensures that the listeners are added only once.

 

But if you show us your code, we may be able to help you better.

 

Regards,

JC

Votes

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
Community Beginner ,
May 18, 2024 May 18, 2024

Copy link to clipboard

Copied

I adjust code to this and stop working 

if (!this.btn1.addEventListener("click", fl_ClickToGoToWebPage_3))
{
   function fl_ClickToGoToWebPage_3() {
	window.open("https://adobe.com", "_blank");
}
}

if (!this.ac_h_btn.addEventListener("click", fl_ClickToGoToWebPage_10))
{
  
function fl_ClickToGoToWebPage_10() {
	window.open("https://www.google.com", "_blank");
}
}

 

my original code is this 

 

this.btn1.addEventListener("click", fl_ClickToGoToWebPage_3);

function fl_ClickToGoToWebPage_3() {
	window.open("https://adobe.com", "_blank");
}

this.ac_h_btn.addEventListener("click", fl_ClickToGoToWebPage_10);

function fl_ClickToGoToWebPage_10() {
	window.open("https://www.google.com", "_blank");
}

this.s_h_btn2.addEventListener("click", fl_ClickToGoToWebPage_26);

function fl_ClickToGoToWebPage_26() {
	window.open("https://adobe.com", "_blank");
}

this.h_g.addEventListener("click", fl_ClickToGoToWebPage_20);

function fl_ClickToGoToWebPage_20() {
	window.open("https://adobe.com", "_blank");
}

this.O_sy_meta.addEventListener("click", fl_ClickToGoToWebPage_21);

function fl_ClickToGoToWebPage_21() {
	window.open("https://yahoo.com", "_blank");
}

this.e_h_btn.addEventListener("click", fl_ClickToGoToWebPage_4);

function fl_ClickToGoToWebPage_4() {
	window.open("https://bing.com", "_blank");
}

 

Votes

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
Community Beginner ,
May 19, 2024 May 19, 2024

Copy link to clipboard

Copied

Thank you @JoãoCésar 

 

I was confused bit with your answer as I saw on the net other answer 

 

if (!this.started)
{
  this.btn1.addEventListener("click", fl_ClickToGoToWebPage_3);

function fl_ClickToGoToWebPage_3() {
	window.open("https://adobe.com", "_blank");
}

this.ac_h_btn.addEventListener("click", fl_ClickToGoToWebPage_10);

function fl_ClickToGoToWebPage_10() {
	window.open("https://www.google.com", "_blank");
}

this.s_h_btn2.addEventListener("click", fl_ClickToGoToWebPage_26);

function fl_ClickToGoToWebPage_26() {
	window.open("https://adobe.com", "_blank");
}

this.h_g.addEventListener("click", fl_ClickToGoToWebPage_20);

function fl_ClickToGoToWebPage_20() {
	window.open("https://adobe.com", "_blank");
}

this.O_sy_meta.addEventListener("click", fl_ClickToGoToWebPage_21);

function fl_ClickToGoToWebPage_21() {
	window.open("https://yahoo.com", "_blank");
}

this.e_h_btn.addEventListener("click", fl_ClickToGoToWebPage_4);

function fl_ClickToGoToWebPage_4() {
	window.open("https://bing.com", "_blank");
}
    this.started = true;
}

 

And it worked , so far so good, I left the page open for while and doesn't open up tab. 

 

 

 

 

Votes

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
Community Expert ,
May 20, 2024 May 20, 2024

Copy link to clipboard

Copied

Nice!

 

You're welcome.

Votes

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
New Here ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

THANK YOU so much for this @JoãoCésar! You saved me!!!

Votes

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
Community Expert ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

LATEST

No problem!

 

Good to know that the answer was helpful.

Votes

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