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
{}
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 ?
public class Test extends Sprite { trace("hello world"); public function Test() { trace("constructor"); } trace("bye world"); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.