开发者

Load Data by HTTPService from Url into Flex text area as a string

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: 10开发者_Go百科00#21#13#2391 that means: in 21 col, 13 row i have the value of 2391 which changes every 1 second. Thanks


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜