The if statement needs to be inside your function...

function playFile(e:keyboardEvent){
//trace statement
//if statement
}

Look at your opening and closing curly braces.