# Access vars in parent.swf from child.swf class

**URL:** <https://forum.kirupa.com/t/access-vars-in-parent-swf-from-child-swf-class/312686>\
**Category:** Uncategorized\
**Created:** [August 10, 2010, 4:28pm UTC](https://forum.kirupa.com/t/access-vars-in-parent-swf-from-child-swf-class/312686 "2010-08-10T16:28:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaqqb](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jaqqb](https://forum.kirupa.com/u/jaqqb)\
**Post date:** [August 10, 2010, 4:28pm UTC](https://forum.kirupa.com/t/access-vars-in-parent-swf-from-child-swf-class/312686/1 "2010-08-10T16:28:49Z")

</div>

Hi!  
I cant access to var in parent movie from class in child.  
I have two swf’s: parent.swf and child.swf. In parent.swf in frame 6 is:

```auto
stop();

            [COLOR=Red]var TestVar:String = "hello!";[/COLOR]

            var imageRequest:URLRequest = new URLRequest("child.swf"); 
            var imageLoader:Loader = new Loader(); 
            imageLoader.load(imageRequest); 
            
            addChild(imageLoader);
            

```

in child.swf is external class called mainClass.as:

```auto
package 
{ 
  
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;
    import flash.utils.*;
    

    public class mainClass extends MovieClip
    {
        
        private var numSlides:int;
        private var selectedThumb:MovieClip;
     //and many vars

        public function mainClass(){
        
            transitionTime = 0.5;
            //some other wars
            
            position();
            loadXml();
            //some functions

          [COLOR=Red] trace(MovieClip(parent.parent).TestVar);[/COLOR] // <--this isn't working - error :null object
            
            return;
        }// end function

```

I was trying use parent, parent.parent, parent.parent.parent etc. and any result - null object error.

How can I fix this?
