1
我從HTTPService在接收以一定的頻率是這樣的字符串: 1#3#234525234 其中 行#列#值 我想顯示成在數據網格實時上面的字符串;目前我的代碼顯示了整個字符串,由上面的字符串組成。 我該如何解決這個問題? 在此先感謝動態數據網格的HTTPService
我有以下代碼
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns="*" creationComplete="srv.send()" >
<mx:Script>
<![CDATA[
import mx.effects.effectClasses.AddItemActionInstance;
import mx.effects.AddItemAction;
import mx.collections.ArrayCollection;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.events.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.InvokeEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.AsyncRequest;
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.rpc.AbstractInvoker;
import mx.controls.Alert;
import mx.core.Container;
import mx.core.IDataRenderer;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.controls.DataGrid;
import flash.display.DisplayObject;
[Bindable]
public var i:Number;
public var source:String;
[Bindable]
public var row:Array;
public var column:Array;
public var value:Array;
public function cycle(source:String):void
{
var data:Array = source.split('#');
i=0;
for each(data in source)
{
row[i]=data[i]
column[i]=data[i+1]
value[i]=data[i+2]
i=i+3
}
}
]]>
</mx:Script>
<mx:HTTPService
id="srv"
url="http://10.15.20.75/server4flex/servlet/Datagen"
method="GET"
/>
<mx:TextArea text="{cycle(srv.lastResult.toString())}" x="10" y="50"
width="699" height="59"/>
<mx:AdvancedDataGrid dataProvider="{source}" liveScrolling="true" id="dg"
x="10" y="117" width="621">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="{row[i]}"
headerText="Riga"/>
<mx:AdvancedDataGridColumn dataField="{column[i]}"
headerText="Colonna"/>
<mx:AdvancedDataGridColumn dataField="{value[i]}"
headerText="Valore"/>
</mx:columns>
</mx:AdvancedDataGrid>
這是行不通的,我想是因爲在你的代碼省略了#分離 – Franky 2010-01-04 14:42:23
是的,當然,你需要添加'VAR數據:數組= source.split('#');'在循環之前。 – Hrundik 2010-01-04 16:41:06
仍然無法正常工作,datagrid什麼都不顯示 – Franky 2010-01-04 16:58:26