Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Of Static Constructor in Actionscript-3?

How do I define a static constructor that is run when class is initialized ?

I can't get it right:

// version a:
{}

// version b:
static {}

// version c:
static function Foo()
{}

// version d:
static ()
{}

// version e:
()
{}

// version f:
static function Foo():void
{}
like image 875
n4pgamer Avatar asked Jun 09 '13 13:06

n4pgamer


1 Answers

Found it out:

public class Test
{
    public function Test()
    {
        trace("normal constructor");
    }

    // static constructor (version a)
    {
        trace("static constructor");
    }
}

For some reason no question was asked about static constructor in AS-3 ?


Dave suggested, I checked: Actionscript initializers don't even need any syntax:
public class Test extends Sprite
{
    trace("hello world");

    public function Test()
    {
        trace("constructor");
    }

    trace("bye world");
}
like image 50
n4pgamer Avatar answered Oct 07 '22 14:10

n4pgamer