开发者

can you override an override in actionscript 3

Just curious, can you override an overri开发者_JS百科de in actionscript 3


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.


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' );
   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜