initialize="createHandler(event)">
import mx.controls.Alert;
private function createHandler(e:Event):void {
b1.addEventListener(MouseEvent.CLICK, myClickHandler);
}
private function removeMyHandlers(e:Event):void {
b1.removeEventListener(MouseEvent.CLICK,myClickHandler);
b2.removeEventListener(MouseEvent.CLICK,myClickHandler);
}
private function myClickHandler(e:Event):void {
Alert.show("This is a log message");
}
click="myClickHandler(event)" />
click="removeMyHandlers(event)" />