Moving character with commands

Hey, i’m very new to action script.

I’m trying to create a program where the character is moved by typing commands, i.e. left, right etc.

There where be a text box on the left the commands are typed into with a process button at the bottom to excecute them.

I need it so the user can type a list of commands and the character with move through them in turn after clicking the process button. i.e.

left
left
right
up

I’ve edited some older code and managed to make character move i.e. ball_mc for 1 command but am now stuck. code below

process_btn.addEventListener(MouseEvent.CLICK, processText);
function processText(m:MouseEvent){
var str:String=txt_area.text;

var words:Array=str.split(/\s+/);
for (var k = 0; k < words.length; k++){
if (words[k]==“left”){
ball_mc.x -= 5;
}
if (words[k]==“right”){
ball_mc.x += 5;
}
if (words[k]==“up”){
ball_mc.y -= 5;
}
if (words[k]==“down”){
ball_mc.y += 5;
}
}
trace(words)
}

any help with be greatly appreciated