> Some objects have .someValue property and some do not. 
 
It sounds like the objects in your dataProvider are instances of various
non-dynamic classes, where some of the classes declare a someValue
property and others don't. 
 
Is this correct? If so, you don't ant to write code like
 
   if (dataProvider[i].someValue == null)
 
because you get a ReferenceError if you access a nonexistend property of
a non-dynamic class. You should only write this if your dataProvider
objects are dynamic.
 
Instead, try
 
   if (dataProvider[i].hasOwnProperty("someValue"))
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Friday, February 16, 2007 4:48 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Cannot access a property or method of a null
object reference



Does anyone know? This would help me immensely. 

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "napearson99" <[EMAIL PROTECTED]> wrote:
>
> What if the property.someValue does not exist? How do I check if the
> reference to dataprovider[i].someValue property is null?
> 
> my dataprovider is an arraycollection and holds different objects. 
> Some objects have .someValue property and some do not. When i try to
> step through it it doesn't like it when it expects a property but it
> is not there.
> 
> "ReferenceError: Error #1069: Property Desc not found on
> DragDrop_inlineComponent1 and there is no default value."
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> , "Paul DeCoursey" <paul@> wrote:
> >
> > if (dataprovider[i].someValue == null){
> > ...
> > }
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> , "napearson99" <napearson99@>
wrote:
> > >
> > > I often get this error and I "usually" know why. Does anyone
know how
> > > to check for a null reference?
> > > 
> > > i.e.
> > > 
> > > if (dataprovider[i].someValue is null){
> > > dothis();
> > > }
> > > 
> > > Where dataprovider[i] does not have a someValue property. I bet
this
> > > is pretty simple and I just don't know the syntax. Thanks in
advance!
> > >
> >
>



 

Reply via email to