Isn't it necessary to creep super () in the constructor when the class extends Sprite in actionscript3?

I always do not call super () when I extend Sprite.
But is there a problem not calling super()?

So far, I have no problems, and I have never seen code that calls super () in a constructor whose class extends Sprite.

What about TextField?
I also have no problem with TextField.

How do I know if I should call super () or not?

+5
source share
3 answers

super() , flash super() . :

public class Parent {
    public function Parent() {
        trace("Parent");
    }
}

public class Child extends Parent {
    public function Child() {
        trace("Child");
    }
}

new Child();
// Parent
// Child

, child

    public function Child() {
        super(); // <-- Added by flash! 
        trace("Child");
    }

, , super(), .

, super()?

, flash super, , , . super(args...) , .

-, , super() , . Flash childs. , .

public class Child extends Parent {
    public function Child() {
        trace("Child");
        super()
    }
}

. :

public class Child extends Parent {
    public function Child() {
        // work before initilizing parent 
        super()
        // work after initilizing parent
    }
}

, , :

public class Child extends Parent {
    public function Child() {
        if(false) super()
    }
}

flash , . , if (false) , .

+28

super() , Flash .

super() , , .

, - this super

+4

. super() , .

+1

All Articles