The reason i is always 5 is that the scope of i is the entire frame. After the loop, i is going to remain 5 forever.

You should use e.currentTarget.name to get the name of the button pressed.

Also, why do you put the instancenames into your array instead of the buttons themselves? If you had put the buttons into your array, you wouldn't have to go through the expensive getChildByName function.