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.coolvisiontest.com/getlinks.php"/>

<mx:Script>
        <![CDATA[
        
                import mx.rpc.events.ResultEvent;
                import mx.collections.ArrayCollection;

                [Bindable] private var LinksFullAC:ArrayCollection;
        
                private function linksResultHandler(event:ResultEvent):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