Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

calling parent function in override function?

Explorer ,
Apr 08, 2013 Apr 08, 2013

[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?

TOPICS
ActionScript
412
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 08, 2013 Apr 08, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines