Hi all I want to use an HTTPService to load some data (number of columns and number of rows) which change randomly by a certain frequency I get the string like freq#ncols#nrows#value. How can i display for example: 1000#21#13#2391 that means: in 21 col, 13 row i have the value of 2391 which changes every 1 second. Thanks
+1
A:
Write a function that formats your raw string, something like:
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];
}
If you were to fill an ArrayCollection to populate a dataProvider, you would need a value object, something like:
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;
}
}
}
Not it's up to you to pick or make the proper component to display the data. That should do it.
George Profenza
2009-12-23 12:17:53
It works! Thank you so much.Now i have to put these random values into an advanced data grid, referring to x row and y col by asynchronous httpservice. Is there any way to do this?Thanks
Franky
2009-12-23 13:48:11
you should probably have an ArrayCollection to store value objects with the data, then feed that ArrayCollection to the datagrid's dataProvider. A value object is just a dumb class you make to store your properties( e.g. row, column, updateTime, value ). Either you have the properties public, or you have private properties and make getters and setters. When you get your data, you populate that array collection with value objects, filling in the properties, with that comes from the http response. Do I make sense ?
George Profenza
2009-12-23 15:51:21