What happens if you don’t try
casting and just call super.InterfaceMethod()? Matt From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tobias Patton 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
|
- RE: [flexcoders] Flex2b2: Problem casting super to an Interf... Matt Chotin