the constructer gets invoked automatically (and its the only function which
does all other overrides this is not the case for) but the super class's
constructer is being called without arguments so whats happening on a code
level is this
super();
On 8/14/07, Alan MacDougall <[EMAIL PROTECTED]> wrote:
>
> 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?
>
> _______________________________________________
> [email protected]
> 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
>
--
j:pn
http://www.memorphic.com/news/
_______________________________________________
[email protected]
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