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
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
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
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");
}
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.
Copy link to clipboard
Copied
Nice!
You're welcome.
Copy link to clipboard
Copied
THANK YOU so much for this @JoãoCésar! You saved me!!!
Copy link to clipboard
Copied
No problem!
Good to know that the answer was helpful.