numerical25
numerical25

Reputation: 10790

can you override an override in actionscript 3

Just curious, can you override an override in actionscript 3

Upvotes: 1

Views: 588

Answers (2)

JeremyFromEarth
JeremyFromEarth

Reputation: 14344

yes you can... here is some pseudo-code

public class Test1 
{
   public function doSomething():void
   {
      trace( 'Test1' );
   }
}

public class Test2 extends Test1
{
   override public function doSomething():void
   {
      super.doSomething();
      trace( 'Test2' );
   }
}

public class Test3 extends Test2
{
   override public function doSomething():void
   {
      super.doSomething();
      trace( 'Test3' );
   }
}

Upvotes: 2

Cory Petosky
Cory Petosky

Reputation: 12646

Yes.

class Foo {
    public function bar():void { }
}

class Foo2 extends Foo {
    override public function bar():void { }
}

class Foo3 extends Foo2 {
    override public function bar():void { }
}

Note that super.bar in Foo3 will necessarily refer to Foo2.bar. Therefore if you expect to be doing this it's sometimes handy to create a protected function in Foo2 that just calls super.bar so that you can access the base implementation when necessary.

Upvotes: 7

Related Questions