Skip to main content
Inspiring
April 8, 2013
Question

calling parent function in override function?

  • April 8, 2013
  • 1 reply
  • 426 views

[AS]

class Parent extends Grandfa

{

    override protected function display()

    {

        //500 lines of code here

    }

}

class Child extends Parent

{

private var isSquare:Boolean;

override protected function display()

{

    if(isSquare)

    {

        //child's display function

    } else {

        //call parent's display() to avoid rewrite 500 lines of code

    }

}

}

[/AS]

Parent has "display()" funciton with 500 lines of code in it. Bur Child acts differently depending on a value in isSquare:Boolean. If it's true, it acts its own action; otherwise, it acts just like the parent does.

Is there a way to act like parent in the override function without rewriting all the 500 lines of code?

This topic has been closed for replies.

1 reply

Inspiring
April 8, 2013

Do you actually call your classes Parent and Child or is this only Pseudo-code?

(You shouldn´t do that if you did)

super should provide what you are looking for.