Apache flex HTTPService将数据作为字符串从Url加载到Flex文本区域
我想使用HTTPService加载一些数据(列数和行数),这些数据以一定的频率随机变化 我得到的字符串类似于freq#ncols#nrows#value。 如何显示,例如: 1000#21#13#2391这意味着:在21列中,13行i的值为2391,每1秒改变一次。Apache flex HTTPService将数据作为字符串从Url加载到Flex文本区域,apache-flex,url,httpwebrequest,httpservice,dataprovider,Apache Flex,Url,Httpwebrequest,Httpservice,Dataprovider,我想使用HTTPService加载一些数据(列数和行数),这些数据以一定的频率随机变化 我得到的字符串类似于freq#ncols#nrows#value。 如何显示,例如: 1000#21#13#2391这意味着:在21列中,13行i的值为2391,每1秒改变一次。 谢谢编写一个函数来格式化原始字符串,例如: public function formatColRowString(source:String):String{ var data:Array = source.split('#
谢谢编写一个函数来格式化原始字符串,例如:
public function formatColRowString(source:String):String{
var data:Array = source.split('#');
return 'in ' + data[1] + ', ' + data[2] + ' I have the value of ' + data[3] +' which changes every ' + data[0];
}
package{
public class RowColObject{
private var _row:int;
private var _col:int;
private var _value:int;
private var _updateTime:int;
public function RowColObject(rawString:String = null){
if(rawString && rawString.length > 0){
var data:Array = rawString.split("#");
_col = data[1];
_row = data[2];
_value = data[3];
_updateTime = data[0];
}
}
public function get row():int{
return _row;
}
public function set row(value:int):void{
_row = value;
}
public function get col():int{
return _col;
}
public function set col(value:int):void{
_col = value;
}
public function get value():int{
return _value;
}
public function set value(value:int):void{
_value = value;
}
public function get updateTime():int{
return _updateTime;
}
public function set updateTime(value:int):void{
_updateTime = value;
}
}
}
如果要填充ArrayCollection以填充数据提供程序,则需要一个值对象,如:
public function formatColRowString(source:String):String{
var data:Array = source.split('#');
return 'in ' + data[1] + ', ' + data[2] + ' I have the value of ' + data[3] +' which changes every ' + data[0];
}
package{
public class RowColObject{
private var _row:int;
private var _col:int;
private var _value:int;
private var _updateTime:int;
public function RowColObject(rawString:String = null){
if(rawString && rawString.length > 0){
var data:Array = rawString.split("#");
_col = data[1];
_row = data[2];
_value = data[3];
_updateTime = data[0];
}
}
public function get row():int{
return _row;
}
public function set row(value:int):void{
_row = value;
}
public function get col():int{
return _col;
}
public function set col(value:int):void{
_col = value;
}
public function get value():int{
return _value;
}
public function set value(value:int):void{
_value = value;
}
public function get updateTime():int{
return _updateTime;
}
public function set updateTime(value:int):void{
_updateTime = value;
}
}
}
不是由您选择或制作适当的组件来显示数据。
应该可以了。它很管用!非常感谢你。现在我必须将这些随机值放入一个高级数据网格中,通过异步httpservice引用x行和y列。有没有办法做到这一点?感谢您可能应该有一个ArrayCollection来存储带有数据的值对象,然后将该ArrayCollection提供给datagrid的数据提供程序。值对象只是用来存储属性(例如行、列、更新时间、值)的哑类。要么将属性设置为公共属性,要么将属性设置为私有属性,并将其设置为getter和setter。当您获取数据时,您将使用值对象填充该数组集合,并使用来自http响应的值填充属性。我说得通吗?