|
Hello List: Given the following classes and interfaces: IInterface.as ----------------- package { import
flash.util.trace; public
interface IInterface { function
InterfaceMethod() : void; } } Base.as ------------- package { import
flash.util.trace; public
class Base implements IInterface { public
function InterfaceMethod() : void { trace(
"Base::InterfaceMethod" ); } } } Derived.as: --------------- package { import
flash.util.trace; public
class Derived extends Base { override
public function InterfaceMethod() : void { trace(
"Derived::InterfaceMethod" ); IInterface(
super ).InterfaceMethod(); } } } What would you expect as the output of the following? var derived : Derived = new Derived(); IInterface( derived ).InterfaceMethod(); I would expect: Derived::InterfaceMethod Base:InterfaceMethod But instead I get: Derived::InterfaceMethod Derived::InterfaceMethod Derived::InterfaceMethod Derived::InterfaceMethod ... (repeats for
ever) It seems the the cast: IInterface( super )
is returning ‘this’ and not the base object for ‘this’.
Is this a bug, or am I misunderstanding something. (Please note that I’m
a C++ programmer and have had little exposure to Java-style interfaces, so I
could be making a very naïve mistake and not know it.) Tobias. Kodak Graphic Communications Canada Company Tobias Patton | Software Developer | Tel: +1.604.451.2700
ext: 5148 | mailto:[EMAIL PROTECTED] | http://www.creo.com -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [flexcoders] Flex2b2: Problem casting super to an Interface Tobias Patton

