What is the best method for creating user definable or user changeable keys in a flash game?
Edit: I meant, user changeable keys. Not user changeable flash buttons. Why would a user need to change the graphic of a button in a game?
What is the best method for creating user definable or user changeable keys in a flash game?
Edit: I meant, user changeable keys. Not user changeable flash buttons. Why would a user need to change the graphic of a button in a game?
I'll answer the second question, "Why would a user need to change the graphic of a button in a game?" I think it would be an awesome idea to have a game like Upgrade Complete that is focused around the user customizing and upgrading the UI. Maybe the game has a set of undifferentiated buttons, and the player has to label and customize them so that she can figure out and remember what they do?
As for custom keys? Capture their keycodes and store them, then test against those keycodes in the input logic. You'll have some sort of options screen where you can set the custom keycodes, then use the settings in the game proper instead of using constants or magic numbers for your action buttons.
The trickiest part, oddly, is displaying the custom keys' names to the user. As far as I can recall, Flash doesn't have a lookup table matching keycodes with key labels. I'm guessing you'd need to create a dictionary yourself with the most important keys, and then just refer to any special cases as something like KEY_1876.
You could create a class that extends Sprite or MovieClip that it's inputs are the height, width, x, y and action (function), and create a new instance of that class each time a user wants to create a new button.