Thanks too!
This works more elegantly for me too.
 

--Keith H--


> You should always use the new "as" operator.
> 
> This article might help:
> http://www.darronschall.com/weblog/archives/000211.cfm
> 
> regards,
> Muzak
> 
> 
> ----- Original Message ----- 
> From: "Amir T Rocker" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, June 21, 2007 11:39 AM
> Subject: Re: [Flashcoders] Type Coercion Failed: Odd behavior.
> 
> 
> > Hi,
> >
> > i experienced the same behaviour using this type of cast
> >
> > var somVar = Caster( Castee );
> >
> > sometimes it works and sometimes it doesnt ...
> > I tried to use the 'as' operator and that suddenly works where 
> above coed failed.
> >
> > var someVar = list.getItemAt( i ) as TypeToCast;
> >
> > I hope maybe that works for you too. I havent figured the casting 
> rules quite yet. So if anybody can explain it
> > its really appreciated :)
> >
> > Best of luck
> > Amir
> >
> > Am 04:07 AM 6/21/2007 schrieben Sie:
> >>Hello,
> >>
> >>I've created a custom class:
> >>
> >>LiquidObject extends Sprite
> >>
> >>I then create several instances of LiquidObject and add them as
> >>children to a parent Sprite.
> >>
> >>If I cycle through and trace the children as such:
> >>
> >>for (var i:int=0;i<parent.numChildren;i++) {
> >>         trace(parent.getChildAt(i));
> >>}
> >>
> >>Each trace shows the correct type of object:
> >>
> >>[object LiquidObject]
> >>
> >>When I tried to access a property specific to LiquidObject
> >>(LiquidObject.selected) it does not recognize this to be a property
> >>because it thinks it's dealing with a general Sprite. So, I attempt
> >>to coerce to type LiquidObject as such:
> >>
> >>for (var i:int=0;i<parent.numChildren;i++) {
> >>         trace(LiquidObject(parent.getChildAt(i)).selected);
> >>}
> >>
> >>Unfortunately, I receive an error stating that I can't coerce type
> >>Sprite to LiquidObject. I would think that this would be allowed
> >>since (a) LiquidObject extends Sprite and (b) 
> parent.getChildAt(i) is
> >>already presenting a type LiquidObject in the trace.
> >>
> >>Any suggestions would be appreciated.
> >>
> >>Thanks in advance.
> >>Paul
> 
> 
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
> 
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to