Super constructors are always called
The super constructor of a class is always called. Regardless of whether a super() method is included.
For example if class A extends class B then on creation the constructor for class B followed by the constructor for class A. This even occurs if there is no super() method in the constructor of class A.
class B{
/**
*
*/
public function A(){
trace('Called First');
}
}
class A extends B{
/**
*
*/
public function B(){
trace('Called Second');
}
}
Produces
Called First Called SecondThere is actually an exception to this if you call method in the super class using the super syntax the super constructor wont be called. For example see the following code.
class B{
/**
*
*/
private function B(){
trace('Called Second');
}
/**
*
*/
public function test():Void{
trace('test method called');
}
}
class A extends B{
/**
*
*/
public function A(){
trace('Called First');
super.test();
}
}
This produces
Called First
test method called
Oddly if you take away the super the method and just use test() then both constructors are called.
Odd stuff it’s probably best practice to avoid putting anything in the constructor.
Comment on Page
If anything is unclear or just plain wrong let us know and should ammend it pretty sharpish. If you visited the page with a particular question leave it and if it's flash related I'll try to answer it.