We had the same issue, and in our case it was an easy fix.  When we read in the 
XML it was returning as an ArrayCollection as long as there were multiple 
nodes.  As you have found, if it was only one node it returned as a generic 
object not an ArrayCollection.  We were already looping through the 
ArrayCollection to populate value objects that we were using to populate our 
list.  So before the loop we added, if xmlObject is an ArrayCollection than 
loop else populate VO with returned data.  Worked without issues ever since.

Robert





________________________________
From: thomas parquier <[email protected]>
To: [email protected]
Sent: Mon, April 19, 2010 9:27:13 AM
Subject: Re: [flexcoders] Problems With my XML Created Array Collection

  
what about xmllistcollection ?;

---
thomas parquier
http://www.web- attitude. fr/realisations/
msn : thomas.parquier@ web-attitude. fr
softphone : sip:webattitude@ ekiga.net
téléphone portable : +33601 822 056



2010/4/19 James <garymoorcroft_ i...@yahoo. co.uk>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>  >
>
>>
> 
>>      
> 
>In my app I have an array collection which populates a tilelist. This array 
>collection is populated by a remote xml file via a http request. Problem is if 
>the xml only has 1 or no nodes I get a null object reference error. I know 
>this is a known problem but I've never been able to find a valid solution for 
>it which could be applied to my code. I've heard of looping through the xml to 
>create an array collection or using xmllist collection but I don't know how 
>these can be done whilst still allowing the data to be displayed in the 
>tilelist. Can anyone help me out please?
>
>>The code for my httpservice, array collcection I'm trying to make and the 
>>result of the http service and the tilelist it populates is shown below. As I 
>>say this all works fine as long as the xml has more than 1 node but causes 
>>the error if it doesn't:-
>
>><mx:HTTPService id="LinksService" result="linksResultHandler( event)" 
>>resultFormat="object" method="POST" url="http://www.coolvisi ontest.com/ 
>>getlinks. php"/>
>
>><mx:Script>
>>      <![CDATA[
>
>>              import mx.rpc.events. ResultEvent;
>>              import mx.collections. ArrayCollection;
>
>>              [Bindable] private var LinksFullAC: ArrayCollection;
>
>>              private function linksResultHandler( event:ResultEven t):void
>>              {
>>                      LinksFullAC= LinksService. lastResult. categories. 
>> category as ArrayCollection;
>>              }
>
>
>>      ]]>
>></mx:Script>
>
>><mx:TileList id="linkChoice"  dataProvider="{LinksFullAC}" height="365" 
>>width="665"/>
>
>>Here's my xml structure:-
>
>><categories>
>> <category>
>>  <id></id> 
>>  <label></label> 
>>  <icon></icon> 
>> </category>
>></categories>
>
>>Obviously I need the array collection to be populated by id, label and icon.
>
>>Thanks for any suggestions.
>
>

 


      

Reply via email to