# Order of things when initializing flash

**URL:** <https://forum.kirupa.com/t/order-of-things-when-initializing-flash/318291>\
**Category:** flash\
**Created:** [January 15, 2011, 6:59pm UTC](https://forum.kirupa.com/t/order-of-things-when-initializing-flash/318291 "2011-01-15T18:59:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DespeRat](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@DespeRat](https://forum.kirupa.com/u/DespeRat)\
**Post date:** [January 15, 2011, 6:59pm UTC](https://forum.kirupa.com/t/order-of-things-when-initializing-flash/318291/1 "2011-01-15T18:59:55Z")

</div>

So, I have this main class:

```auto
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:

```auto
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”?
