Copy link to clipboard
Copied
Finally getting back into web banners. I made a banner with a dynamically created disclaimer at the end. (clicking on the 'important info' button attaches a new div to the stage that can scroll the really long disclaimer).
The timeline is set to loop after a few seconds. Once it loops, though, the close button of the disclaimer no longer works. Any idea why?
I've uploaded a reduced file with the issue.
can access the .fla file here:
https://www.dropbox.com/s/w3g6b7nzx60asba/vanilla_Disclaimer_test.zip?dl=0
(Forum will not allow me to attach the file directly for some reason)
Copy link to clipboard
Copied
you're probably re-adding that listener creating more and more copies of that div each time you enter that frame.
prevent that by using:
if(!this.alreadyExecuted){
//add your listener here
this.alreadyExecuted = true;
}
Copy link to clipboard
Copied
Thank you.
It looks like the issue was actually with the function creating the listener that creates the popup div and not the one adding the listener to the close button. (It's funny that the div-creator button still worked, but not the close button!) I used your check on that first function and it seems to work.
I'm still so confused by how variables work locally v globally in Animate!
Copy link to clipboard
Copied
you're welcome.
the issue was you were probably creating multiple objects with the same reference because of the multiple listeners and the close button couldn't reference multiple objects with the same reference.