Constructor Class1 : this = object of type Class 1; inParam = Constructor Class1 : this = object of type Class 2; inParam = Constructor Class2 : this = object of type Class 2; inParam = Constructing new object of type Class3 with parameter 3 Constructor Class1 : this = object of type Class 3; inParam = 3 Constructor Class2 : this = object of type Class 3; inParam = 3 Constructor Class3 : this = object of type Class 3; inParam = 3
Calling myFunction on object of type Class3 myFunction Class3 : this = object of type Class 3 myFunction Class2 : this = object of type Class 3 myFunction Class1 : this = object of type Class 3 Calling notInTheSubclass() notInTheSubclass Class2: this = object of type Class 3 notInTheSubclass Class2: this = object of type Class 3 notInTheSubclass Class1: this = object of type Class 3Two notes here:
- the constructors of the two superclasses are called without parameter before actually creating the object. Due to the call to super() , the constructor of Class1 is called twice. Then the constructors are called again with parameter, in top-down order.
- The function notInTheSubclass exists in Class1 and Class2, not in Class3. See how it gets called twice for Class2. When running this in the debugger, you can see how the call to super.notInTheSubclass() in Class2 actually calls itself before calling the function in Class1.
Constructing new object of type Class3 with parameter 3 Constructor Class1 : this = object of type Class 3; inParam = 3 Constructor Class2 : this = object of type Class 3; inParam = 3 Constructor Class3 : this = object of type Class 3; inParam = 3
Calling myFunction on object of type Class3 myFunction Class3 : this = object of type Class 3 myFunction Class2 : this = object of type Class 3 myFunction Class1 : this = object of type Class 3 Calling notInTheSubclass() notInTheSubclass Class2: this = object of type Class 3 notInTheSubclass Class1: this = object of type Class 3Here, the constructors are called only once, top-down, with parameter. Furthermore, the call to super.notInTheSubclass() in Class2 immediately refers to Class1, as expected in normal class hierarchy. *Solution*
The workaround for this bug, when not exporting for player 7, is threefold:
- Make the call to super as early as possible. It might be necessary to save the state of the object if it gets changed by the call to super.
- Call the super with the same parameters, even if they are not all used in the function in the superclass. If you omit parameters, the second call to the class itself loses data.
- Keep the signature of the functions identical. The AS2 compiler does not check on this, so overloading functions is not possible.

