Copy link to clipboard
Copied
To call a function at the start of a project, I have been using
stage.addEventListener(Event.ENTER_FRAME, sampleFunction)
function sampleFunction (e:Event)
{stage.removeEventListener(Event.ENTER_FRAME, sampleFunction);
dothis}
Is there a better way to do something like this?
use:
sampleFunction()
function sampleFunction ():void
{
//dothis;
}
Copy link to clipboard
Copied
use:
sampleFunction()
function sampleFunction ():void
{
//dothis;
}
Copy link to clipboard
Copied
Thanks. Was so close
Copy link to clipboard
Copied
close?
Copy link to clipboard
Copied
No, your answer was correct, thank you. I just meant I tried a bunch of things before posting the question and they were similar to what you posted, just not quite there.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Thanks for the reply. Will try this.
Copy link to clipboard
Copied
In the main Document Class, asuming you call it MainDocument:
public class MainDocument extends MovieClip {
//constructor
public function MainDocument() {
super();
doSomething();
}
public function doSomething():void {
//do something
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now