Let’s use the following example to illustraite my dillema:
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:
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.