0
votes

I want to create an instance of a subclass from inside a static superclass method. Here is an example:

class Base
{
    public static function createSubclassInstance()
    {
        //What do I do here?
        return new this.getSubclassType();
    }
}

class Sub extends Base
{
}

I want to create a new Sub instance by calling:

var s:Sub = Sub.createSubclassInstance();
1
I think you can't extend static methods. - user216441
I am a bit confused. You are creating a Sub instance, why not just instantiate it like you would normally? - sberry
sberry2A: There is other functionality that I want to wrap inside the createSubclassInstance() which is irrelevant to the question - Fragsworth
Looks like M28 is right, can't extend static methods - Fragsworth
I'd really, really! like to know why you are trying to do this. - ocodo

1 Answers