Back when I started coding in AS3 for Flash, I would create a separate event handler for each button. After a few revisions on these projects, I quickly realized that this was completely impractical. I found a far easier solution by creating a single onclick handler function for all the buttons, and switch based on the name of the button. Now, I share it with you.
btn_1.addEventListener(MouseEvent.CLICK, linkHandler); btn_2.addEventListener(MouseEvent.CLICK, linkHandler); function linkHandler(me:MouseEvent):void { switch(me.target.name) { case 'btn_1': // The code for button 1 break; case 'btn_2': // The code for button 2 break; } }



In an effort to create a local micro-search for a client, I used the 