# Accessing vars in SuperClass from SubClass

**URL:** <https://forum.kirupa.com/t/accessing-vars-in-superclass-from-subclass/327362>\
**Category:** flash\
**Created:** [February 24, 2012, 6:21pm UTC](https://forum.kirupa.com/t/accessing-vars-in-superclass-from-subclass/327362 "2012-02-24T18:21:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ineedsleep](https://avatars.discourse-cdn.com/v4/letter/i/e5b9ba/32.png) [@Ineedsleep](https://forum.kirupa.com/u/Ineedsleep)\
**Post date:** [February 24, 2012, 6:21pm UTC](https://forum.kirupa.com/t/accessing-vars-in-superclass-from-subclass/327362/1 "2012-02-24T18:21:54Z")

</div>

So, how would you create a class that can access a variable in the class where the subClass was created(superclass), I realise this might be unclear so in example

```php

package {
import flash.display.MovieClip;
public class Main extends MovieClip {
public var demoString:String = "TEST";
public static var newClass:SubClass;
public function Main() {           
// constructor code           
 init();        
}        
public function init():void{     
newClass = new SubClass();     
     } 
   }
 }

```

```php

package {
public class SubClass extends Main{    
public function SubClass() {
// constructor code            
trace(super(demoString));        
   }    
  }
}

```

I cant read demoString from the SuperClass and when I try and test this code I get this error?  
Error: Error #2136: The SWF file file:///C|/Users/classes/Main.swf contains invalid data.  
at Main/init()  
at Main()
