6 Replies Latest reply on Nov 27, 2007 2:12 PM by bpapau

    HTTPService Help

    bpapau
      Hi everyone,

      I hate to make another topic about this, but I'm at my wits end getting this to work. Been 2 days and I haven't made any progress. I've included a full version of my code below.

      I'm just trying to get a proof of concept going to collect this chart data, but I can't seem to get it to work using AS. I've been trying to debug it, but all I get is a "Source not found" eventually. I have confirmed that the data is correct (the debug tells me that much) but why it wont display on the chart is byond me....

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      initialize="config.send()"
      >
      <mx:Script>
      <![CDATA[
      import mx.charts.chartClasses.Series;
      import mx.charts.series.LineSeries;
      import mx.charts.LineChart;
      import mx.containers.Panel;
      import mx.containers.Canvas;
      import mx.events.*;
      import mx.rpc.events.*;
      import mx.controls.Alert;

      private function useHTTPservice(param:Object,URL:String,result_fxn:Function=null,result_format:String="e4x "):void
      {
      var contact:HTTPService = new HTTPService();
      contact.resultFormat = result_format;
      contact.url = URL;
      contact.method = "POST";
      if (result_fxn != null ) {
      contact.addEventListener("result", result_fxn);
      }
      contact.addEventListener("fault", httpFault);
      contact.send();
      }

      private function dataReceived(evt:ResultEvent):void
      {
      var MainCanvas:Canvas = new Canvas;
      MainCanvas.setStyle("backgroundColor","white");
      MainCanvas.percentHeight = 100;
      MainCanvas.percentWidth = 100;
      this.addChild(MainCanvas);

      var newPanel:Panel = new Panel;
      newPanel.percentHeight = 100;
      newPanel.percentWidth = 100;
      MainCanvas.addChild(newPanel);

      var Chart:LineChart = new LineChart;
      Chart.percentHeight = 100;
      Chart.percentWidth = 100;
      Chart.dataProvider = evt.result.point;

      var newSeries:Series = new Series;


      Chart.addChild(newSeries);

      var Line:LineSeries = new LineSeries;
      Line.yField = "CO2_BDROOM";
      newSeries.addChild(Line);

      newPanel.addChild(Chart);

      }

      private function httpFault(evt:FaultEvent):void
      {
      Alert.show("fail");
      }

      private function configkiosk(event:ResultEvent):void
      {
      var DB_Connect:Object = new Object;
      var URL:String = new String;
      URL = " http://192.168.11.12/getdata.php?length=day"

      useHTTPservice(DB_Connect,URL,dataReceived);
      }

      ]]>
      </mx:Script>


      <mx:HTTPService id="config" url=" http://localhost/KIOSK_CONFIG.xml" result="configkiosk(event)" />


      </mx:Application>