开发者

AS3 - Access of undefined property (Static variable)

I'm trying to change a static variable in the class's constructor. At the start I have:

public static var mainReference:Main;
public static var timerReference:Timer;
public var timer:Timer = new Timer(1000);

Th开发者_运维知识库is is so my static functions can access main and timer. At Main's constructor I have:

mainReference = this;
timerReference = timer;

The problem is, the first gives no error when I compile it, but the second tells me Access of undefined property (timerReference).


It might have something to do that the flash player is trying to access timerReference as a class var instead of a static var.

Try this:

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

Now you are telling flash player to explicitly access mainReference as a class var and timerReference as a static class var.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜