Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I dont know what you are really looking after but <a href="http://www.flexafterdark.com/docs/ActionScript-Responder" rel="noreferrer">here</a> or <a href="http://www.flexafterdark.com/docs/Flex-HttpService" rel="noreferrer">here</a> for example, are way to use <code>AsyncToken</code> and <code>AsyncResponder</code></p> <p><strong>Edit:</strong></p> <ol> <li>your <code>dataList</code> have to be <code>Bindable</code></li> <li>Don't set <code>dataList</code> on each loop iteration</li> <li>You have to call you function <code>getResults</code> at some point when your results are ready</li> <li><code>event</code> in <code>result</code> function is an <code>Event</code> but also a <code>ResultEvent</code> where there is a <code>result</code> field containing your data</li> </ol> <p>Which may look as this (untested):</p> <pre><code>[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) { ac.addItem( {row: data[i], column: data[i+1], value: data[i+2]} ); } return ac; } private function result(event:ResultEvent) : void { dataList = getResults( String(event.result) ); } </code></pre> <p><strong>Edit2</strong>:</p> <p>this is a working example using a simple php file to get the data running on a local web server.</p> <blockquote> <p>Flex part</p> </blockquote> <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.collections.ArrayCollection; import mx.rpc.AsyncToken; import mx.rpc.Responder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.mxml.HTTPService; [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 { //here do whatever you want to manage the error you received } public function onCreationComplete() : void { var service : HTTPService = new HTTPService(); service.url = "http://127.0.0.1/getDatas.php"; service.resultFormat = "text"; var token : AsyncToken = service.send(); token.addResponder(new mx.rpc.Responder(result, fault)); } ]]&gt; &lt;/mx:Script&gt; &lt;mx:AdvancedDataGrid id="dg" dataProvider="{dataList}" 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> <blockquote> <p>Php part (getDatas.php)</p> </blockquote> <pre><code>&lt;?php print "1#c1#v1#2#c2#v2#3#c3#v3"?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload