# How to access a var from stage using a class?

**URL:** <https://forum.kirupa.com/t/how-to-access-a-var-from-stage-using-a-class/305048>\
**Category:** flash\
**Created:** [February 18, 2010, 1:31pm UTC](https://forum.kirupa.com/t/how-to-access-a-var-from-stage-using-a-class/305048 "2010-02-18T13:31:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zen08](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zen08](https://forum.kirupa.com/u/Zen08)\
**Post date:** [February 18, 2010, 1:31pm UTC](https://forum.kirupa.com/t/how-to-access-a-var-from-stage-using-a-class/305048/1 "2010-02-18T13:31:29Z")

</div>

Hi guys!

I need a clear understanding on my problem:

I have var on my stage and i want my class to be able to access  
that var.

Here’s what is on my main.fla:

```auto

import ShapeOuts;

var ShapeDetect = 0;

var shaped:ShapeOuts = new ShapeOuts();

function showShape()
{
    trace("Show Shape");
    shaped.grow();
}

showShape();

```

Here’s what is on my class:

```auto

package
{
    import flash.events.Event;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
        
    public class ShapeOuts extends MovieClip
    {
        public function ShapeOuts()
        {
            addEventListener(Event.ADDED_TO_STAGE, grow);
        }
        public function grow():void
        {
            if(MovieClip(root).ShapeDetect == 0)
            {
                trace("ShapeDetect = " + MovieClip(root).ShapeDetect);
            }
        }
    }
}

```

i keep getting this error: Cannot access a property or method of a null object reference.

Am i missing something here? Hope this one makes sense.
