import flash.events.Event;
import mx.events.FlexEvent;
public function initConsoleTab():void{
Application.application.currentState = "Console";
this.timerObj.stop();
this.timerObj = new Timer(refreshTime*1000,1);
this.timerObj.addEventListener(TimerEvent.TIMER, requestUpdateConsoleTab);
this.timerObj.start();
command_box.addEventListener(FlexEvent.ENTER,onCommand);
}
public function requestUpdateConsoleTab(event:Event):void{
}
public function onResultConsoleTab(info:Object):void{
for(var i:String in info.data){
console_box.text += (info.data[i] + "\n ");
}
console_box.text += "\n";
console_box.verticalScrollPosition = console_box.textHeight-40;
return;
}
public function onCommand(event:Event):void{
var commandStr:String = command_box.text;
command_box.text = "";
console_box.text += "[FMGConsole] ";
console_box.text += commandStr;
console_box.text += "\n "
console_box.verticalScrollPosition = console_box.textHeight-40;
commandStr.toLowerCase();
var commandArr:Array = commandStr.split(" ");
if(commandArr.length < 1){
return;
}
if(commandArr[0] == "cmd"){
onExecuteCommand(null, commandArr[1] ? commandArr[1] : null
, commandArr[2] ? (commandArr.slice(2)).toString() : null)
}else if(commandArr[0] == "moveleg"){
onMoveLeg(commandArr[1] ? commandArr[1] : null,
commandArr[2] ? commandArr[2] : null,
commandArr[3] ? commandArr[3] : null);
}else if(commandArr[0] == "createleg"){
onCreateLeg(commandArr[1] ? commandArr[1] : null,
commandArr[2] ? commandArr[2] : null,
commandArr[3] ? commandArr[3] : null);
}else if(commandArr[0] == "hangupleg"){
onHangupLeg(commandArr[1] ? commandArr[1] : null,
commandArr[2] ? commandArr[2] : null,
commandArr[3] ? commandArr[3] : null);
}else {
console_box.text += ("InValid command"+ "\n ");
}
}