flex HttpService 获取实时数据
private function init():void{
var time:Timer= new Timer(5000);
time.addEventListener(TimerEvent.TIMER,onTimer);
time.start();
}
private function onTimer(evt:TimerEvent):void{
htpService=new HTTPService();
htpService.url="http://192.168.1.113:8080/coalmine/dataEnginer.action";
htpService.addEventListener(ResultEvent.RESULT,result);
htpService.addEventListener(FaultEvent.FAULT,faultevent);
htpService.send();
}
debug 发现onTimer一直都响应但数据不是最新的,而一直是编译时间的数据,为什么
[解决办法]
var httpSrv:HTTPService = new HTTPService();
//var httpSrv:HTTPService = Global.getHTTPSrv();
try
{
httpSrv.requestTimeout = Global.g_requestTimeout;
httpSrv.url = Global.g_ServerRootURL + "ServerPort/getrealtimeinfo.aspx";
httpSrv.resultFormat = "text";
httpSrv.showBusyCursor = true;
//绑定事件
httpSrv.addEventListener(ResultEvent.RESULT, onHttpSrvResult_ReadInfo);
httpSrv.addEventListener(FaultEvent.FAULT, onHttpSrvError);
//发送请求
httpSrv.send();
}
finally
{
httpSrv = null;
}