我正在尝试更改类的构造函数中的静态变量。一开始我有:
public static var mainReference:Main;
public static var timerReference:Timer;
public var timer:Timer = new Timer(1000);
这是我的静态函数可以访问main和timer。在Main的构造函数中,我有:
mainReference = this;
timerReference = timer;
问题是,编译时第一个没有错误,但第二个告诉我未定义属性的访问(timerReference)。
答案 0 :(得分:5)
Flash播放器尝试访问timerReference
作为类var而不是静态var可能有一些事情要做。
试试这个:
this.mainReference = this;
Main.timerReference = this.timer;
现在,您要告诉Flash播放器将mainReference
显式地作为类var和timerReference
作为静态类var进行访问。