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

How to run code only on start up

New Here ,
May 16, 2024 May 16, 2024

Copy link to clipboard

Copied

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

Views

58

Translate

Translate

Report

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

Votes

Translate

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

assuming html5/canvas

 

if(!this.alreadyExecuted){

this.alreadyExecuted=true;

.

.

// code to execute once

}

Votes

Translate

Translate

Report

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