gpt4 book ai didi

actionscript-3 - Actionscript-3 中静态构造函数的语法?

转载 作者:行者123 更新时间:2023-12-04 12:22:20 25 4
gpt4 key购买 nike

如何定义在类初始化时运行的静态构造函数?

我无法理解:

// version a:
{}

// version b:
static {}

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

// version d:
static ()
{}

// version e:
()
{}

// version f:
static function Foo():void
{}

最佳答案

发现了:

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

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

出于某种原因,没有人问关于 AS-3 中的静态构造函数的问题?

Dave建议,我检查: Actionscript 初始化程序甚至不需要任何语法:
public class Test extends Sprite
{
trace("hello world");

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

trace("bye world");
}

关于actionscript-3 - Actionscript-3 中静态构造函数的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17010360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com