In ActionScript 2, the call to super() in the constructor of a class inheriting from another class had to be the first statement within the constructor. If you didn't add it explicitly yourself, it was added for you.
In ActionScript 3, super will still be added for you if you did not include it yourself, but now you are allowed to place it anywhere within your constructor, even after other statements; it no longer has to be the first statement in your constructor.
ActionScript Code:
package {
public class SubClass extends SuperClass {
protected var value:int;
public function SubClass(value:int = 0) {
this.value = value;
super(20);
}
}
}
0 评论:
发表评论