Hi, I know u can't instantiate an interface, which wasnt what I was trying to do ;), I was declaring a variable to be of type SomeInterface (instantiating it with SomeConcreteClass), which apparently is not regarded by flash then of being of type Object as well. Got it figured out now ;)
Thanks H -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julien Vignali Sent: Wednesday, February 01, 2006 12:49 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] interfaces and objects Well, you can't instanciate an interface, you need first a concrete class that implements the interface... Your code should be: interface IWorldPart {} class SomeWorldPartSubclass implements IWorldPart {} var myPart:SomeWorldPartSubclass = new SomeWorldPartSubclass(); myCollection.addItem(myPart); j.c.wichman a écrit : > Hi, > i'm using a collection, which requires items of type Object to be added. > > I've declared an interface which gives me something like: > - interface IWorldPart > - a class implementing WorldPart > > now somewhere else i do: > var myPart:IWorldPart = new SomeWorldPartSubclass(); > myCollection.addItem (myPart); > > The last statement gives a type error, if i replace the first with var > myPart:WorldPart = new ... all goes well. > >>From what I can remember from Java (which I admit, seems ages ago ;)), >>this > first should be no problem at all. > > Does anyone know why this is not allowed in Flash? > > thanks in advance. > Hans > > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

