Reputation: 1714
I am venturing development on mobile apps using Flex.
I am trying to use HttpService to connect to a url which returns an XML data.
<s:HttpService id="test" url="UrlToConnectTo" />
And in the script:
private function init() :void
{
test.send();
}
And the lastResult of the service I am binding to a List..
<s:List id="list" top="0" bottom="0" left="0" right="0"
dataProvider="{test.lastResult.Item.FiscalYear }"
labelField="ItemDescription"/>
Are there other alternate means of handling data returned by services? I would like to inspect the data, but I am not sure what type of data it is after being bound to the list (array, arraycollection??).
Side Note: I can also get the data via JSON, but I am unable to bind the data retrieved properly to the list control.
Appreciate any links / insights provided.
Upvotes: 0
Views: 492
Reputation: 39408
Are there other alternate means of handling data returned by services?
Yes,s, use a result event handler. Conceptually something like this:
<s:HttpService id="test" url="UrlToConnectTo" result="onResult(event)" />
And your handler method:
protected function onResult(event:ResultEvent):void{
trace(event.result);
// convert XML result to XMLListCollection
var myCollection : XMLListCollection = new XMLListCollection(event.result as XML);
// convert array result to ARrayCollection
var myCollection : ArrayCollection = new ArrayCollection(event.result as Array);
}
Most likely you'll want to convert your data from whatever is returned into something more useful in Flex. XML to an XMLList or an Array to an ArrayCollection, as two examples.
Upvotes: 1