No, you can't instantiate an interface. But I don't think Hans was doing
that.

There's no problem with typing:
interface IWorldPart {}
class SomeWorldPartSubclass implements IWorldPart  {}
var myPart:IWorldPart = new SomeWorldPartSubclass();   /* Note
INTERFACE-typed var, not concrete */
myCollection.addItem(myPart);

Works fine for me on a quick test. A sanity check of
trace(myPart instanceof Object);  //traces true
shows that you should be able to use the myPart variable everywhere that an
Object is expected.

Ian

On 2/1/06, Julien Vignali <[EMAIL PROTECTED]> wrote:
>
> 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);
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to