开发者

Explicitly overriding constructors in ActionScript3

All,

I ran into this funny thing in a different post. It was pointed out to me that you can explicitly override a constructor... which doesn't seem necessary, and I am a little surprised it even compiles. Take a look:

public class TestClass
{
    public function TestClass() {}
}

public class TestClass2 extends TestClass
{
    public o开发者_JAVA百科verride function TestClass2() {}
}

Explicitly calling override on the constructor might just be a no-op, as it is certainly not necessary. My question: Is there a subtlety here that I am missing? Does explicitly overriding the constructor tell the compiler something?


public class TestClass
{
    public function TestClass() {}
}

public class TestClass2 extends TestClass
{
    public override function TestClass2() {
       super();//this makes call to the default constructor
}


i think it's just a bit of freedom provided by as3 syntax :)
imho bytecode of an swf with overriden contstructor is equal to one of swf with a normal one

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜