RE: [flexcoders] cast/convert to a child class?

2009-10-19 Thread Gordon Smith
ArrayCollection does not have any idea what type of elements you put into it. 
You can have an ArrayCollection full of Dog instances, or an ArrayCollection 
full of Cat instances, or an ArrayCollection full of Cats and Dogs (i.e., 
Pets). But all are just ArrayCollections and no casting is required.

You're probably thinking of Vector. vs Vector.. There are indeed 
different types, and one cannot be cast to the other.

Gordon Smith
Adobe Flex SDK Team

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of coder3
Sent: Thursday, October 15, 2009 3:54 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] cast/convert to a child class?



Hi All,

I have a arrayCollection of class Pet,
and i have a child class Dog extends Pet,

is there a way to convert the arrayCollection of Pet to arrayCollection of
Dog?
--
View this message in context: 
http://www.nabble.com/cast-convert-to-a-child-class--tp25917283p25917283.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] cast/convert to a child class?

2009-10-15 Thread Paul Andrews
coder3 wrote:
> Hi All,
>
> I have a arrayCollection of class Pet,
> and i have a child class Dog extends Pet,
>
> is there a way to convert the arrayCollection of Pet to arrayCollection of
> Dog?
>   
If your array references Pet objects, you cannot cast them as Dog() 
because they aren't Dog objects.
If your array references Dog objects, you can cast them as Dog() because 
they are Dog objects.

Dogs are an extension of Pet and a Pet object does not have the class 
attributes (or methods) that a Dog object would.

Paul



[flexcoders] cast/convert to a child class?

2009-10-15 Thread coder3

Hi All,

I have a arrayCollection of class Pet,
and i have a child class Dog extends Pet,

is there a way to convert the arrayCollection of Pet to arrayCollection of
Dog?
-- 
View this message in context: 
http://www.nabble.com/cast-convert-to-a-child-class--tp25917283p25917283.html
Sent from the FlexCoders mailing list archive at Nabble.com.