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

How to run code only on start up

New Here ,
May 16, 2024 May 16, 2024

How can i run code once when the animation loads? Everything works fine but i now want to add some code to the start to set up, like stop movieclip and hide objects stuff like that, but if i put it at the top of my script, it runs every time i get to that frame.

 

Thanks

277
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

Community Expert , May 16, 2024 May 16, 2024

Hi.

 

Create a custom boolean flag in the first frame of the main timeline. Like this:

if (!this.started)
{
    // your startup code goes here
    this.started = true;
}

 

I hope this helps.

 

Regards,

JC

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

Hi.

 

Create a custom boolean flag in the first frame of the main timeline. Like this:

if (!this.started)
{
    // your startup code goes here
    this.started = true;
}

 

I hope this helps.

 

Regards,

JC

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 ,
May 16, 2024 May 16, 2024
LATEST

assuming html5/canvas

 

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

.

.

// code to execute once

}

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