Using Add Event Listener
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()"> <mx:Script> private function initApp():void { myButton.addEventListener(MouseEvent.CLICK, clickHandler); } private function clickHandler(event:MouseEvent):void { myLabel.text="The " + event.type + " event was dispatched by " + event.target.id; } </mx:Script> <mx:Label id="myLabel"/> <mx:Label id="altLabel"/> <mx:Label id="ctrlLabel"/> <mx:Label id="shiftLabel"/> <mx:Button id="myButton" label="Click Me"/> </mx:Application>