I agree with joshstrike...that code is chaos. You might also think of using a dictionary to index your buttons against their value

PHP Code:
var codeByButton:Dictionary = new Dictionary();
codeByButton[bt0] = 0;
codeByButton[bt1] = 1;
...