ok then try this; try{ varName; trace('variable exists'); }catch(e:Error){ trace('variable does not exist'); }
Clinton D. Judy wrote On 01/31/2008 05:53 PM: > > I tried that, and it tells me the variable is undefined and cannot test > it. Which doesn't seem to make a whole lot of sense. I tried your method > first, and don't understand why it's not working. > > -----Original Message----- > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > [mailto:flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com>] On > Behalf Of yigit > Sent: Thursday, January 31, 2008 10:45 AM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: Re: [flexcoders] How do I test if a variable is defined? > > to test whether a variable exists or not > > if(varName) > trace('exists'); > else > trace('does not exist'); > > Clinton D. Judy wrote On 01/31/2008 05:34 PM: > > > > No other explanation needed, really. How do I see if an > > object/variable exists before I test other conditions of it? > > > > Unnecessary explanation: I use two completely separate mxml interfaces > > > that both use one as script file. One program is just missing some > > information that the other one has. I'd like to keep using the same > > script file, but it references a variable that exists in one file that > > > doesn't exist in the other file, and I need to make sure it exists > > before I use it. > > > > Clinton Judy > > > > Web Developer > > > > Glenn O. Hawbaker, Inc. > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > <http://www.mail-archive.com/flexcoders%40yahoogroups.com> > Yahoo! Groups Links > >