Using same sample from Adobe doc to show a chart but trying to load
data with HTTPService. Don't know why it doesn't show anything.
Please any suggestions, thanks.
This is the XML file:
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<mes label='Enero'>
<dia label='01/01/2006' value='200'/>
<dia label='02/01/2006' value='300'/>
<dia label='03/01/2006' value='400'/>
<dia label='04/01/2006' value='500'/>
</mes>
</data>
This is the MXML file:
<?xml version="1.0"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="get_data()">
<mx:Script><![CDATA[
import mx.rpc.http.HTTPService;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
[Bindable]
private var datos:XMLList;
private var hs:HTTPService;
private function get_data():void{
hs=new HTTPService();
hs.resultFormat='e4x';
hs.url='datos.xml';
hs.addEventListener("result",getResult_data);
hs.addEventListener("fault",getFault_data);
hs.send();
}
private function getFault_data(event:FaultEvent):void{
Alert.show("Error.", "Error", Alert.OK
, this);
}
private function getResult_data(event:Event):void{
datos=new XMLList(hs.lastResult);
}
]]></mx:Script>
<mx:Panel title="LineChart and AreaChart Controls Example"
height="100%" width="100%" layout="horizontal">
<mx:LineChart id="linechart" height="100%" width="45%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{datos}">
<mx:verticalAxis>
<mx:CategoryAxis categoryField="mes"/>
</mx:verticalAxis>
<mx:series>
<mx:AreaSeries yField="dia"
form="curve" displayName="dia"/>
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{linechart}"/>
</mx:Panel>
</mx:Application>