Copy link to clipboard
Copied
[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?
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now