import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
[Bindable] private var callLegsData:ArrayCollection = new ArrayCollection();
private var refreshTime:int = 5; private var timerObj:Timer = new Timer(refreshTime*1000,1);
public function initCallLegsTab():void{
Application.application.currentState = "Call Legs";
this.timerObj.stop();
this.timerObj = new Timer(refreshTime*1000,1);
this.timerObj.addEventListener(TimerEvent.TIMER, requestUpdateCallLegsTab);
onExecuteCommand(null,"listlegs" , null);
}
public function requestUpdateCallLegsTab(event:Event):void{
onExecuteCommand(null,"listlegs" , null);
this.timerObj.stop();
}
private function onResultCallLegsTab(info:Object):void{
trace("result:"+result);
parseNDisplayResult_CallLegsTab(info);
this.timerObj.start();
}
private function parseNDisplayResult_CallLegsTab(info:Object):void{
var displayData:ArrayCollection = new ArrayCollection ();
var tempString:String;
var headerArray:Array = new Array();
headerArray= info.data[info.data.length -1].split(",");
var tempObj:Object;
var i:int;
if(info.data.length <=2){
tempObj = new Object();
tempObj["No active Call Leg"]= " ";
displayData.addItem( tempObj);
callLegsData = displayData;
return;
}
for( i = (info.data.length -2) ; i>0 ; i--){
tempString = info.data[i];
var tempArray:Array= tempString.split(",");
tempObj = new Object();
var count:int = 0;
var j:String;
for( j in headerArray){
tempObj[headerArray[j]] = tempArray[count++];
}
displayData.addItem(tempObj);
}
callLegsData = displayData;
}