# Calling a Subclass Method from a Superclass

**URL:** <https://forum.kirupa.com/t/calling-a-subclass-method-from-a-superclass/246929>\
**Category:** flash\
**Created:** [December 16, 2007, 6:00pm UTC](https://forum.kirupa.com/t/calling-a-subclass-method-from-a-superclass/246929 "2007-12-16T18:00:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nogame](https://avatars.discourse-cdn.com/v4/letter/n/f17d59/32.png) [@nogame](https://forum.kirupa.com/u/nogame)\
**Post date:** [December 16, 2007, 6:00pm UTC](https://forum.kirupa.com/t/calling-a-subclass-method-from-a-superclass/246929/1 "2007-12-16T18:00:31Z")

</div>

Let’s use the following example to illustraite my dillema:

```auto

package {
 
  public class Superclass
  {
    public var $thisVar:String = undefined;
 
    function Superclass(){
       $thisVar = 'woot';
    }
  }
}
 
package {
 
  public class Subclass extends Superclass
  {
    function Subclass(){
       trace($thisVar);
    }
  }
}

```

Given the above example, the following code when used inside the Superclass would cause a Stack Overflow:

```auto
subclass:Subclass = new Subclass();

```

Because of this, I can’t really use any of the subclass methods.

Since I’m somewhat new to proper OOP practices, I’m also wondering whether or not this is a good idea. The current goal of the relationship between these two classes is:

- extending the subclass should allow me to use $variables defined in the superclass on subclass methods.
- by instantiating the subclass i can call some of the subclass functions from inside my superclass

Since I could probably set this up in a more efficient manner, any OOP advice here would be appreciated.
