Thanks for the response everyone! I have made the changes that was
suggested and still I'm getting an error msg for null reference. To
Jay, it is one element of an array collection (that has like 5-6
different objects), not one field or string. The line of code that the
compiler is pointing to is...
private var tempAC:ArrayCollection = new ArrayCollection();
private function myFunc(event:ResultEvent):void
{
if(event.result.blah.blah is ArrayCollection){ //if array has multiple
elements
myArrayCollection = event.result.blah.blah;
}else{ //if array has just one element
tempAC.addItem(event.result.blah.blah); //this is where I'm
getting the null error
myArrayCollection = tempAC;
}
}
My xml would look similar to this...
<response>
<values>
<value>
<id>123</id>
<name>kyle</name>
<somethingElse>blah blah</somethingElse>
</value>
</values>
</response>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Darin Kohles
Sent: Thursday, May 15, 2008 11:08 AM
To: [email protected]
Subject: Re: [AFFUG Discuss] How to read ArrayCollection with one
element?
simply move the following line inside the else clause:
myArrayCollection = tempAC;
On Thu, May 15, 2008 at 11:08 AM, <[EMAIL PROTECTED]>
wrote:
>
> I see one problem in the code.
>
> tempAC is defined only in else class.
>
>
> Is the event.result.blah.blah a string if there is only one element?
or is
> it an array/arraycllection with one element?
>
>
> Jay Jayaraman
> Central Billing Services
> Financial Management and Planning
> (404) 498-8453 (W)
> (404) 273-7131 (C)
>
>
> "Tung Lee" <[EMAIL PROTECTED]>
> Sent by: [EMAIL PROTECTED]
>
> 05/15/2008 10:36 AM
>
> Please respond to
> [email protected]
> To
> [email protected]
> cc
> Subject
> Re: [AFFUG Discuss] How to read ArrayCollection with one element?
>
>
>
>
> Kyle,
>
> I ran into that problem not too long ago.
> I don't know the logic behind it, but it looks like that
ArrayCollection
> does not like single or null element.
>
> What I end up doing was adding empty elements to my XML and than
sending
> through filterFunction which filters out the null elements.
>
> Not sure if you can modify the source data or not, but that how I end
up
> make it work...
>
> Tung Lee
>
> On Thu, May 15, 2008 at 10:02 AM, Kyle Patterson
> <[EMAIL PROTECTED]> wrote:
> Does anyone know how to use an ArrayCollection that just has one
element; I
> keep getting a popup error saying "property or method of a null object
> reference". The ArrayCollection needs to work whether it has one
element or
> multiple elements. Here's my code, what am I doing wrong???
>
>
>
> private var myArrayCollection:ArrayCollection;
>
>
>
> private function myFunc(event:ResultEvent):void
>
> {
>
> if(event.result.blah.blah is ArrayCollection){ //if array has multiple
> elements
>
> myArrayCollection = event.result.blah.blah;
>
> }else{ //if array has just one element
>
> var tempAC:ArrayCollection = new ArrayCollection();
>
> tempAC.addItem(event.result.blah.blah);
>
> }
>
> myArrayCollection = tempAC;
>
> }
>
>
>
> Thanks in advance,
>
>
>
> Kyle
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe
in the
> subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink
> -------------------------------------------------------------
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe
in the
> subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink
> -------------------------------------------------------------
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe
in the
> subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink
> -------------------------------------------------------------
--
Darin Kohles
RIA Application Developer
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in
the subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the
subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------