Mega Code Archive

 
Categories / Flex / Event
 

Use a separate call to addEventListener() method for each instance

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="createHandlers(event)">     <mx:Script>     public function createHandlers(e:Event):void {         b1.addEventListener(MouseEvent.CLICK, submitForm);         b2.addEventListener(MouseEvent.CLICK, submitForm);     }     private function submitForm(e:Event):void {         trace(e.currentTarget.id);     }   </mx:Script>     <mx:Button id="b1" label="Click Me" />     <mx:Button id="b2" label="Click Me Too" /> </mx:Application>