AS3 - 访问未定义的属性(静态变量)

时间:2011-07-12 08:34:32

标签: flash actionscript-3

我正在尝试更改类的构造函数中的静态变量。一开始我有:

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)。

1 个答案:

答案 0 :(得分:5)

Flash播放器尝试访问timerReference作为类var而不是静态var可能有一些事情要做。

试试这个:

this.mainReference = this;
Main.timerReference = this.timer;

现在,您要告诉Flash播放器将mainReference显式地作为类var和timerReference作为静态类var进行访问。