When evaluate obj["foo"] and there's no "foo" field on "obj", you get undefined.
And *this[prop].text * is the same as *(this[prop]).text* So when prop is the name of an invalid property (like "myInput6"), it's the same as calling: * (undefined).text* Which is never going to work. Replace your test for *if(this[prop].text)* with *if(prop in this)* -Josh On Tue, Nov 4, 2008 at 2:53 PM, timgerr <[EMAIL PROTECTED]> wrote: > Thnaks for the help, here is the problem that I am getting. I will > show you my code: > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute" > > <mx:Script> > <![CDATA[ > public var obj:Object = new Object; > public function DoIt():void > { > NewObj(); > } > public function NewObj():void > { > obj.myInput1 = 'Odd'; > obj.myInput2 = 'Even'; > obj.myInput3 = 'Odd'; > obj.myInput4 = 'Even'; > obj.myInput5 = 'Odd'; > obj.myInput6 = 'Even'; > obj.myInput7 = 'Odd'; > > for (var prop:String in obj) > { > if(this[prop].text) { > trace('found'); > this[prop].text = obj[prop]; > } > } > } > ]]> > </mx:Script> > <mx:TextInput id="myInput1" text="Enter text here"/> > <mx:TextInput id="myInput3" text="Enter text here"/> > <mx:TextInput id="myInput5" text="Enter text here"/> > <mx:TextInput id="myInput7" text="Enter text here"/> > <mx:Button id="Click" click="DoIt()"/> > </mx:Application> > > I get an error "ReferenceError: Error #1069: Property myInput6 not > found on Objects and there is no default value." Not sure whey > myInput6 is being seen since I am doing the if statement. > > Any ideas? > > Thanks for the help > timgerr > > > --- In flexcoders@yahoogroups.com, Alex Harui <[EMAIL PROTECTED]> wrote: > > > > if(this[prop].text) { > > trace('found'); > > this[prop].text = obj[prop]; > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of timgerr > > Sent: Monday, November 03, 2008 11:36 AM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] How to test for object and do other things > > > > > > Hello all, > > I have a question for ya, have an object and I want to test for a flex > > ui component with that name. Here is what I am trying to do. > > > > I have these flex UI items: > > <mx:TextInput id="myInput1" text="Enter text here"/> > > <mx:TextInput id="myInput3" text="Enter text here"/> > > <mx:TextInput id="myInput5" text="Enter text here"/> > > <mx:TextInput id="myInput7" text="Enter text here"/> > > > > I have an object: > > obj.myInput1 = 'Odd'; > > obj.myInput2 = 'Even'; > > obj.myInput3 = 'Odd'; > > obj.myInput4 = 'Even'; > > obj.myInput5 = 'Odd'; > > obj.myInput6 = 'Even'; > > obj.myInput7 = 'Odd'; > > > > so I can do this to see what is in the object: > > for (var prop:String in obj) > > { > > trace(prop, ' is ' + obj[prop]); > > } > > > > and I will get: > > myInput1 is Odd > > myInput2 is Even > > myInput3 is Odd > > myInput4 is Even > > myInput5 is Odd > > myInput6 is Even > > myInput7 is Odd > > > > Now I want to test to see if we have the textinput items for each > > return of obj > > > > I want to do something like this: > > for (var prop:String in obj) > > { > > trace(prop, ' is ' + obj[prop]); > > if(prop.text) { > > trace('found'); > > prop.text = obj[prop]; > > } > > This should find > > myInput1 > > myInput3 > > myInput5 > > myInput7 > > > > and add the information in the object to the textinput items. > > > > but the problem is that the above code dosnt work, how can I do this? > > Thanks for the help, > > timgerr > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." Like the cut of my jib? Check out my Flex blog! :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] :: http://flex.joshmcdonald.info/ :: http://twitter.com/sophistifunk