Compare these two situations:
class SuperClass
{
private var list:Array;
public function SuperClass()
{
list = new Array();
}
}
class SubClass extends SuperClass
{
// when instantiated, the list variable is automatically initialized
}
This is as it should be. The superclass constructor is executed when the
subclass is instantiated, as long as the subclass doesn't override it.
class Button
{
private var clip:MovieClip;
public function Button(clip:MovieClip)
{
clip.onRelease = Delegate.create(this, handlerMethod);
}
}
class SpecialButton extends Button
{
// does not override the superclass constructor
}
In this case, code such as "var foo:Button = new SpecialButton(clip);"
does NOT execute the superclass constructor. Instead, I need this:
class SpecialButton extends Button
{
public function SpecialButton(clip:MovieClip)
{
super(clip); // now it works
}
}
My understanding of inheritance is that I should not need to explicitly
call the superclass constructor as long as I'm not overriding or
extending that method of the superclass. What gives? Is it a language quirk?
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com