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

How do I put event listeners in the global script?

Explorer ,
Feb 07, 2018 Feb 07, 2018

I simply want to place event listeners in the Animate CC global script so that I am not cluttering up frame 1.  How would  I put the following script in the global script window and change it so the listener can actually find the instance "nextBut" at the root level? Thanks in advance.

this.nextBut.addEventListener("click", doNext.bind(this));

function doNext() {

  alert("foo")

}

654
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

correct answers 1 Correct answer

LEGEND , Feb 07, 2018 Feb 07, 2018

It's probably a bad idea to put bare code in the global script. If you have initialization code that needs to be run, wrap it in an init function and then call it in the first frame.

Or just "clutter up" frame 1. Animate doesn't care. Worry about what works, not IDE aesthetics.

Translate
LEGEND ,
Feb 07, 2018 Feb 07, 2018
LATEST

It's probably a bad idea to put bare code in the global script. If you have initialization code that needs to be run, wrap it in an init function and then call it in the first frame.

Or just "clutter up" frame 1. Animate doesn't care. Worry about what works, not IDE aesthetics.

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