Hi,

when you declare them like this:
var myObj1:MyInterface
addChild (myObj1) wont work

if you do
var myObj1:Sprite = ...
addChild (myObj1)

it probably will.

The thing is that you essentially provide two different interfaces for your
object. By extending Sprite you satisfy the DisplayObject requirement for
addChild(). By implementing your interface you satisfy the requirement for
your own class that the objects have to of a certain interface. Telling your
own class, here is a display object isn't going to work, since it needs the
interface, vice versa telling the display list here is my own interface
isn't going to work either, you have to pass the objects in the form
expected in both cases.

hth,
JC




On Fri, Aug 7, 2009 at 10:00 AM, Tom Huynen <tomhuy...@gmail.com> wrote:

> Hi!
>
> I have a tiny little problem with the following:
>
> I have two classes that should have the same dataType in order to use them
> in a third class. So I created an Interface that both of them implement.
> The two classes extend Sprite because they have a visual representation.
> However, when I try to add them to the displayList flash doesn't recognise
> them as a displayObject.
> I read that many people at this moment cast them back to a displayObject
> but
> that to me feels like a workaround.
>
> Anybody any suggestions?
>
> Thanks!
>
> Tom
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to