[AS2.0] Multiple Super Calls irrgularity


interface I 
{ 
  ... 
} 

class A 
{ 
  public function A() 
  { 
    ...
  }
}

class B extends A implements I 
{ 
  public function B()
  { 
    super(); 
    trace("B Called");
  } 
} 

class C extends B 
{ 
  public function C() 
  { 
    super();
    trace("C Called");
  }
}

Thats the schematic of my the specific area of my program thats causing me trouble. In output i get “C Called” only. I’m guessing that on the return of the super() call to A() then it jumps back to C(), but id expect that the call stack could handle multiple super calls. Anyone experienced something similar to this? Any reply is greatly appreciated

-Matt ‘Deviant’ Lloyd

That is strange, it should begin by calling the top-most class constructor and continue its way down the inheritance chain to the class being instantiated. I’m assuming you used: var c:C = new C(); or something along those lines to do this.

And for the record, unless you specifically call super as the first line of the constructor, Flash will do it for you so there is really no point in calling it [U]unless[/U] you want to pass parameters to the super class constructor.

Sorry I couldn’t be of much help but when I test this it works as it should :slight_smile:

Resolved

This was my own mistake, the constructor wasnt the same name as the class, Amature mistake, sorry guys!

Any way that was a good example to peep into the call heirarchy.:glasses:

Something I did find out in this was that Setter’s are called before the constructor too. Which to me seems incredibly stupid, since a setter could call a method that needs instance variables…

Can anyone give me an idea to why this happends?