Skip to main content
Known Participant
April 11, 2013
Answered

Best Way to Call Function at start of project?

  • April 11, 2013
  • 2 replies
  • 905 views

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?

This topic has been closed for replies.
Correct answer kglad

use:

sampleFunction()

function sampleFunction ():void

{

//dothis;

}

2 replies

Amy Blankenship
Legend
April 12, 2013

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

    }

}

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 12, 2013

use:

sampleFunction()

function sampleFunction ():void

{

//dothis;

}

withertonAuthor
Known Participant
April 12, 2013

Thanks. Was so close

kglad
Community Expert
Community Expert
April 12, 2013

close?