hi Gordon, 
one question please. 
how come the following code passes the if test even though myVar 
clearly exists?


private var myVar:Object;
private function test():void
{
  myVar = new Object();

  if(!("myVar" in this))
  {
    Alert.show("passes");
  }
}

thanks
bod

--- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> 
wrote:
>
> if ("idName" in this)
> 
> - Gordon
> 
> -----Original Message-----
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of alpharythms
> Sent: Wednesday, April 05, 2006 3:19 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Testing if a variable exist?
> 
> I imagine this is something simple that I am missing but is there a
> way to test a variable to see if it exist.
> 
> Specifically I have several components with IDs.  So I can access 
them
> like this.idName or this["idName"].
> 
> I need to way to know if this["idName"] is a valid variable.  I've
> tried if(this[idName]==null) or undefined.  The trouble is I get a
> runtime error as soon a this[idName] that doesn't exist comes up.
> 
> Here is what I'm try do to.  I've loading an XML document and then
> looping through the attributes in a node.  If a
> this[currentAttributeName] component exist then I bind it to the 
data
> in the XML.  If I come across an attribute that doesn't exist on 
the
> Flex form than I just want to ignore it.
> 
> Everything works great until I hit an attribute that doesn't 
exist. 
> So I just need a way to test for the existance of a component with 
the
> given ID name.
> 
> Thanks,
> Adam
> 
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to