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

Best Way to Call Function at start of project?

Community Beginner ,
Apr 11, 2013 Apr 11, 2013

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?

TOPICS
ActionScript
843
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 , Apr 11, 2013 Apr 11, 2013

use:

sampleFunction()

function sampleFunction ():void

{

//dothis;

}

Translate
Community Expert ,
Apr 11, 2013 Apr 11, 2013

use:

sampleFunction()

function sampleFunction ():void

{

//dothis;

}

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 Beginner ,
Apr 11, 2013 Apr 11, 2013

Thanks. Was so close

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 ,
Apr 11, 2013 Apr 11, 2013

close?

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 Beginner ,
Apr 11, 2013 Apr 11, 2013

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.

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 ,
Apr 12, 2013 Apr 12, 2013
LATEST

you're welcome.

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 Beginner ,
Apr 11, 2013 Apr 11, 2013

Thanks for the reply. Will try this.

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
Guide ,
Apr 11, 2013 Apr 11, 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

    }

}

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