Well, you can't instanciate an interface, you need first a concrete
class that implements the interface...
While you cannot instantiate an interface, you can assign an object
that is an instance of a class that does implement the interface to a
variable that is typed to the interface.
Your code should be:
interface IWorldPart {}
class SomeWorldPartSubclass implements IWorldPart {}
var myPart:SomeWorldPartSubclass = new SomeWorldPartSubclass();
myCollection.addItem(myPart);
I think what the OP is saying is that he wants to do this (based on
your example):
var myPart:IWorldPart = new SomeWorldPartSubclass();
...which compiles just fine, but the compiler baulks at the following
statement...
myCollection.addItem(myPart);
If I read correctly, the addItem method is expecting one argument of
type Object, and the compiler seems to think that an object of type
IWorldPart (i.e. of a class implementing the IWorldPart interface)
cannot be stored in a variable of type Object. I don't have time to
test this, but if this really is the case then it's a compiler bug.
--
Steve Webster
Head of Development
Featurecreep Ltd.
www.featurecreep.com
14 Orchard Street, Bristol, BS1 5EH
0117 905 5047
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders