I need a few pointers on how to create multiple buttons programmatically with different event handlers, or rather: differently parametrized event handlers. My real use is a bit more complex, but it comes down to this: I need a button that can delete itself upon getting clicked.
var Buttons:Vector.<Button> = new Vector.<Button>;
var newButton = new Button;
var int = Buttons.push(newButton);
newButton.addEventListener(MouseEvent.CLICK, button_clickHandler);
// pseudocode
button_clickHandler(event:MouseEvent):void {
if (event.button = i) { delete button i}
}
I can't figure out the way to do this in Flash, except doing something silly like checking mouse position during the click event against all buttons, and then figuring out which one was clicked.