The bad part, as I said, is that only Adobe can fix this.

So, until that happens (if it happens someday...), I just do a cast to
DisplayObject on the argument at call time and carry on.

You can always file an enhancement request.
https://bugs.adobe.com/

regards, Muzak

----- Original Message ----- From: "Juan Pablo Califano" <califa010.flashcod...@gmail.com>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Saturday, August 08, 2009 7:39 PM
Subject: Re: [Flashcoders] Interface for displayObjects


Hi,

I've had the same problem and couldn't find a real solution.

The simplest thing to do, for me, was just using the as operator:

var obj:ISomeInterface = new ConcreteObject();

container.addChild(obj as DisplayObject);

I like that it doesn't require an extra variable and it doesn't clutter your
code too badly.

The only real solution, I think, it's on Adobe's hands, since DisplayObject
is a concrete class defined natively by the player (well, sort of, at
runtime it behaves like an abstract class since you can't create an instance
with new ...).

The cool part is that the change should be simple and backward compatible.
Just provide an IDisplayObject interface and have DisplayObject implent it.
Then change method signatures in the dispay list API to require
IDisplayObject instead of DisplayObject. In your code, your interface can
extend IDisplayObject, and that should solve the problem:

interface ISomeInterface extends IDisplayObject

class ConcreteObject extends Sprite implements ISomeInterface

The bad part, as I said, is that only Adobe can fix this.

So, until that happens (if it happens someday...), I just do a cast to
DisplayObject on the argument at call time and carry on.

Cheers
Juan Pablo Califano


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to