So, I have this main class:
public class Chloe extends MovieClip {
public var key:Controls = new Controls();
public static var box:Sprite = new Sprite();
G.boxRef = box;
public static var cow:Cow=new Cow();
and in the Cow class i have this:
public function Cow() {
addEventListener(Event.ENTER_FRAME,update);
trace(Chloe.box)
and it throws me TypeError: Error #1009: Cannot access a property or method of a null object reference.
if I try to trace(G.boxRef) in Cow constructor - it traces undefined in the first frame, but next frames are fine.
But why? Both variable “box”, and reference to it are declared before declaring variable “cow”?