Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 代码是否在创建每个新对象时运行?_Flash_Actionscript 3 - Fatal编程技术网

Flash 代码是否在创建每个新对象时运行?

Flash 代码是否在创建每个新对象时运行?,flash,actionscript-3,Flash,Actionscript 3,如果我有以下代码: class Stand { public static const STAND_LIST:Array = new Array(); STAND_LIST[0] = new Array(); STAND_LIST[1] = new Array(); public function Stand() { //constructor } } 是否每个新创建的支架实例都会创建支架列表[0]?还是只创建一次 如果创建了Stand的每个新实例,如何使其只运行一次?(如

如果我有以下代码:

class Stand {

public static const STAND_LIST:Array = new Array();
STAND_LIST[0] = new Array();
STAND_LIST[1] = new Array();

public function Stand() {
    //constructor
    }
}
是否每个新创建的支架实例都会创建支架列表[0]?还是只创建一次


如果创建了Stand的每个新实例,如何使其只运行一次?(如初始化const)

静态为类初始化一次;它们不会在每次创建新类实例时初始化

关于ActionScript中静态初始值设定项的有用链接:


简要讨论何时初始化static。

它是静态的,因此对于
Stand
类,
Stand.Stand_LIST
,只需一次,但它对于
Stand
var Stand:Stand=new Stand()的实例不可用;stand.stand_LIST;//错误
。另外,您可能希望使用这个
公共静态var STAND_LIST:Array=[[],[]响应的.thx!。现在我知道它只是运行一次从您的评论和bedwyr