title: HTTPService AsyncToken and AsyncResponder example
body: <p>Where can I find an example of Flex application which implements an HTTPService asynchronously called by an AsyncToken and an AsyncResponder?
  Thanks in advance</p>
  
  <p>the httpservice send a string like this with a certain frequency:</p>
  
  <p>row#column#number#row#column#number#row#column#number#....</p>
  
  <p>EDITED CODE:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;mx:Application creationComplete="onCreationComplete()" 
  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;
  &lt;mx:Script&gt;
  &lt;![CDATA[
      import mx.rpc.remoting.RemoteObject;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.http.mxml.HTTPService;
      import mx.rpc.AsyncRequest;
      import mx.rpc.AsyncResponder;
      import mx.rpc.AsyncToken;
      import mx.collections.ArrayCollection;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
      import mx.controls.AdvancedDataGrid;
      import mx.controls.Alert;
      import mx.rpc.IResponder;
  
  
      [Bindable]
      public var dataList:ArrayCollection;
  
      public function getResults(source:String) : ArrayCollection {
      var ac:ArrayCollection = new ArrayCollection();
      var data:Array = source.split('#');
      for (var i:int = 0; i &lt; data.length; i += 3) {
      var dataObj:Object = {row: data[i], column: data[i+1], value: data[i+2]};     
      ac.addItem(dataObj)
      }
  
      return ac;
      }
      public function result(event:ResultEvent):void{
      dataList = getResults( String(event.result) );
      }
      public function fault(event:FaultEvent) : void {
      dataList = getResults(String(event.fault)); 
      }
  
  public function onCreationComplete():void
  {
  var service:HTTPService = new HTTPService();
  service.url = "http://10.15.20.75/server4flex/servlet/Datagen";
  service.resultFormat = "text";
  var token:AsyncToken = service.send(dataList);
  token.addResponder(new mx.rpc.Responder(result, fault));
  }
  
  ]]&gt;
  &lt;/mx:Script&gt;
  &lt;mx:AdvancedDataGrid id="dg"
  dataProvider="{result}"  
  liveScrolling="true"  
      x="10" y="10" width="621"
      verticalScrollPolicy="on"
   &gt;
          &lt;mx:columns&gt;
                      &lt;mx:AdvancedDataGridColumn dataField="row"
             headerText="Riga"/&gt;
                      &lt;mx:AdvancedDataGridColumn dataField="column"
             headerText="Colonna"/&gt;
                      &lt;mx:AdvancedDataGridColumn dataField="value" 
             headerText="Valore"/&gt;
          &lt;/mx:columns&gt;
   &lt;/mx:AdvancedDataGrid&gt;
  
   &lt;/mx:Application&gt;
  </code></pre>