
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
178
|
Chapter 6: Inheritance
trace("p is: " + p);
// Show the initial value of p, assigned by
// the superclass. This will yield 10 even though p has
// been modified on the current object.
trace("super.p is: " + super.p);
}
}
// Usage:
var bInstance:B = new B( );
bInstance.showP( ); // Displays:
// p is: 15
// p is: 5
// super.p is: 10
This uncommon super behavior is caused by the compiler’s automatic conversion of
ActionScript 2.0 code to ActionScript 1.0 code (which is a necessary evil guarantee-
ing that most ActionScript 2.0 code will work in Flash Player 6). The behavior may
be changed in future versions of the language. You should, therefore, avoid using it.
Member Access from Inherited, Overriding,
and Overridden Instance Methods
We’ve now seen how to override instance methods, static methods, instance proper-
ties, and static properties. We’ve also seen how to invoke overridden instance meth-
ods. With all these overridden methods and properties afoot, we’re forced to
consider some tricky scope questions. For example, from within an instance method
that overrides another instance method, what properties and methods are accessi-
ble? What about from within the overridden version of the method? What if the
properties and methods being accessed are, themselves, overridden?
Before