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
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
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
Copy link to clipboard
Copied
assuming html5/canvas
if(!this.alreadyExecuted){
this.alreadyExecuted=true;
.
.
// code to execute once
}