Also, I get the same problem when myVar is a gui. eg <mx:TextArea id="myVar"/> in mx.core.Application.application.
Then, from another component i call if(!("mx.core.Application.application.myVar" in mx.core.Application.application)) { mx.controls.Alert.show("myVar doesnt exist"); } //passes Actually, that if test passes in the main mxml application file as well. But if i loose the "mx.core.Application.application" its okay again. confused? i am. --- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> wrote: > > When I change > > > > private var myVar:Object; > > > > to > > > > public var myVar:Object; > > > > the alert doesn't come up, as expected. Changing it to protected doesn't > fix it. > > > > So apparently "in" only works on public -- not private or protected -- > things, which I didn't know. I'll ask our AS3 designers whether that's > the intended behavior. > > > > - Gordon > > > > > > -----Original Message----- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of bhaq1972 > Sent: Friday, April 07, 2006 2:47 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: Testing if a variable exist? > > > > 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" <gosmith@> > > 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 > > > > http://groups.yahoo.com/group/flexcoders/ > > > > [EMAIL PROTECTED] > > > > http://docs.yahoo.com/info/terms/ > -- 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/