Obsidian-Shark/aphrosia-opensource — pull request #1 by Void-Director (2014-02-01 20:15:05+00:00)
Title: Reduced redundancy in the ButtonHandler

(As written on http://forum.fenoxo.com/thread-6642-page-55.html)

When I was reading through the source code for the button handler I noticed you use 15 variables to represent your various buttons. You then go on to create 45 different functions that are basically identical to interact with those buttons. Unfortunately my knowledge of Action Script is rather poor as I am not a flash developer. However, I suspected you could reduce this using an array and by passing parameters to the click handler rather than having 15 of them.

It turns out this is a bit tricky in AS3 but I managed to do it with a little help from stack overflow. Anyhow I managed eliminate all of the redundant code with the game to still working as intended. Again my knowledge of Action Script is very limited so you will probably want to review. I also had to make minor changes to the other files in order to make it so they use the slightly changed syntax (1 function with parameters instead of 15).