    // ActionScript file
    import flash.events.Event;

    import mx.events.FlexEvent;

    public function initConsoleTab():void{
        Application.application.currentState = "Console";
        // Initialize refresh timer
        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);
        //command_box.addEventListener(FlexEvent.ENTER,onCo
    }

    public function requestUpdateConsoleTab(event:Event):void{
        // do nothing
    }

    public function onResultConsoleTab(info:Object):void{
        // do nothing
        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{
        // do nothing
        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;

        // command array
        commandStr.toLowerCase();
        var commandArr:Array = commandStr.split(" ");

        if(commandArr.length < 1){
            //console_box.text += ("No input"+ "\n ");
            return;
        }

        if(commandArr[0] == "cmd"){
            // It is a commend

            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 ");
        }

    }