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.
精彩评论