Hi,
No confusion here ;) except maybe for my fuzzy explanation ;).
I did:
interface IWorldPart
class WorldPart implements IWorldPart
class SomeWorldPartSubclass extends WorldPart

then either
var myPart:WorldPart = new SomeWorldPartSubclass(); or var myPart:IWorldPart
= new SomeWorldPartSubclass();

As you described, however collection.addItem (myPart) only works in the
first case and not in the second.
Probably becoz flash thinks IWorldPart is not an object. I changed it to :
var myPart:Object = new SomeWorldPartSubclass(); 
And it works fine (just as var myPart:WorldPart = new
SomeWorldPartSubclass();) by the way.

Thanks for your comments, 
H

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas
Sent: Wednesday, February 01, 2006 12:36 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] interfaces and objects

Um... not quite sure what you're up to here - but it sounds like you're
getting a bit confused between IWorldPart and WorldPart.

What you need is:
interface IWorldPart
class SomeWorldPartSubclass implements IWorldPart

then
var myPart:IWorldPart = new SomeWorldPartSubclass();

should be fine.

_OR_

interface WorldPart
class SomeWorldPartSubclass implements WorldPart

then
var myPart:WorldPart = new SomeWorldPartSubclass();

Not quite sure why your description mentions both IWorldPart and WorldPart -
unless WorldPart implements IWorldPart..? In which case you're looking for:

interface IWorldPart
class WorldPart implements IWorldPart
class SomeWorldPartSubclass extends WorldPart

then either
var myPart:WorldPart = new SomeWorldPartSubclass(); or var myPart:IWorldPart
= new SomeWorldPartSubclass();

should both work...

HTH,
  Ian


On 2/1/06, j.c.wichman <[EMAIL PROTECTED]> wrote:
>
> 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.
>
_______________________________________________
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