Expand my Community achievements bar.

I made a HTTP request using a <mx:HTTPService> tag and I want to use a XML variable to store the result, however, the sy

Avatar

Former Community Member
In my application I want to use an array to navigate a part
of a XML file from an external XML file on web. I first use a
<mx:HTTPService> to link to the .xml file, and then create a
XML object to hold the "lastResult" in the <mx:Script> tag.
It doesn't show an error in the Flex builder, however, when I
execute the application, the system show an error message as below:



TypeError: Error #1009: Cannot access a property or method of
a null object reference.







Here are the code I used:









<?xml version="1.0" encoding="utf-8"?>

<mx:Application

xmlns:mx="
http://www.adobe.com/2006/mxml"

layout="absolute"

creationComplete="creationCompleteHandler()">



<mx:Script>

<![CDATA[



public function creationCompleteHandler():void {

feedRequest.send();

}



var MyXML:XML = new XML(feedRequest.lastResult);

]]>

</mx:Script>



<mx:HTTPService id="feedRequest" url="
http://sweb.cityu.edu.hk/50685791/Adv_trialPosts.xml"
useProxy="false" />





<mx:Repeater id="PostRepeator"
dataProvider="{MyXML.channel.item}">

<custom:PostPanel id="PostHolder" width="{sizeWidth}"
height="{sizeHeight}" title="{PostRepeator.currentItem.title}" >

<mx:TextArea width="100%" height="100%"
text="{PostRepeator.currentItem.title}" />

</custom:PostPanel>

</mx:Repeater>



</mx:application>







Did I missed something or got some misconceptions??



Thx a lot!
4 Replies

Avatar

Level 2
look into result and fault events for the HttpService
tag

Avatar

Level 3
You I think you could solve your probler if you change the
repeater dataprovider to {feedRequest.lastresult.channel.item} and
also if you want to use a variable to bind data you have to use the
metatag [Bindable] above its declaration.

Avatar

Former Community Member

quote:




Originally posted by:
mab_bond


You I think you could solve your probler if you change the
repeater dataprovider to {feedRequest.lastresult.channel.item} and
also if you want to use a variable to bind data you have to use the
metatag [Bindable] above its declaration.





yea I tried that before. But I really need to use an array to
hold the external XML, an then extract only some of the nodes to be
a DataProvider to the repeater.

So I need to use the XML object.



anyaway, thanks very much!

Avatar

Level 3
If that's what you want then you need to convert your xml in
an array, creating a function that performs that action for
you.