AS3 - access to the undefined property (static variable)

I am trying to change a static variable in a class constructor. In the beginning I:

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

This means that my static functions have access to the main and timer. I have the main constructor:

 mainReference = this; timerReference = timer; 

The problem is that the first does not give compilation errors, but the second tells me access to the undefined (timerReference) property.

+4
source share
1 answer

Perhaps something that the flash player is trying to access timerReference as a class var instead of a static var.

Try the following:

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

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

+5
source

All Articles