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

Listener breaks on Loop

New Here ,
Aug 06, 2021 Aug 06, 2021

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)

 

166
Translate
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 ,
Aug 07, 2021 Aug 07, 2021

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;

}

Translate
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 ,
Aug 10, 2021 Aug 10, 2021

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!

Translate
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 ,
Aug 10, 2021 Aug 10, 2021
LATEST

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.

Translate
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