Thanks, your solution worked.

If I think about it, I'm puzzled. Just like UIComponent, the IClosable
interface doesn't have the isClosed property either. So when I cast it
that interface, it should fail but it doesn't. 

If that's how interfaces work. Then casting it as IUIComponent
interface should have worked too. 

--- In [email protected], "Mike Krotscheck" <[EMAIL PROTECTED]>
wrote:
>
> UIComponent doesn't have a property called isClosed, therefore your
> attempt to access that property on an instance cast to UIComponent will
> throw an error. What you need to do is have each class implement an
> interface called IClosable or something along those lines, and cast to
> that.
>  
> public function checkDoor(c:IClosable):Boolean
> {
>     return c.isClosed;
> }
>  
> 
> Michael Krotscheck
> 
> Senior Developer
> 
>                           
> 
> RESOURCE INTERACTIVE
> 
> <http://www.resource.com/> www.resource.com <http://www.resource.com/> 
> 
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of dsds99
> Sent: Tuesday, February 19, 2008 4:54 PM
> To: [email protected]
> Subject: [flexcoders] Polymorphism....?
> 
> 
> 
> I have 2 unrelated classes that extend UIComponent ultimately..;)
> and each class implements a boolean property called "isClosed"
> 
> Passing these classes into the function as untyped. 
> 
> If I don't cast, it works. Trying to understand why it doesn't work
> this way.
> 
> A compile time error occurs in the if statement. But isn't this where
> polymorphism kicks in even though I am casting it to a higher class in
> the chain.
> 
> public function checkDoor(c:*):void{
> if((c is UIComponent).isClosed == true){
> trace("opened");
> }
> }
> 
> 
> 
>  
> 
> 
> We support privacy and confidentiality. Please delete this email if it
> was received in error.
> 
> What's new ::
> Capitalize on the social web | The Open Brand, a new book by Kelly
> Mooney and Dr. Nita Rollins, available March 2008 | www.theopenbrand.com
>


Reply via email to