var buttons = new Array<Button>(); // buttons will be stored here
function deleteButton(buttonID:Int) {
var button = buttons[buttonID]; // get the button from the array
button = FlxDestroyUtil.destroy(button); // destroy the button
}
// This will create 10 buttons labeled "Button 0", "Button 1", ...
for (i in 0...10) {
var button = new FlxButton(i * 100, i * 50, 'Button $i', deleteButton.bind(i)); // bind the index i to pass the button ID to deleteButton:Int->Void, deleteButton now becomes Void->Void
buttons.push(button);
}