Add addEventListener() inline with Button's initialize property

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.controls.Alert;
private function myClickHandler(event:Event):void {
Alert.show("This is a log message");
}
</mx:Script>
<mx:Button id='b1' label="Click Me"
initialize='b1.addEventListener(MouseEvent.CLICK, myClickHandler,false, 1);' />
</mx:Application>
Related examples in the same category