It would appear as if you never call createHandlers.

Try this version...


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="createHandlers(event)">
        
        
<mx:Script>
        <![CDATA[

import mx.controls.Alert;

public function createHandlers(e:Event):void {
b1.addEventListener(MouseEvent.CLICK, submitForm);
b2.addEventListener(MouseEvent.CLICK, submitForm);
}

private function submitForm(e:Event):void {
// Handle event here.
Alert.show("Current Target: " + e.currentTarget.id);
Alert.show(" You clicked me");
}
]]></mx:Script>


<mx:HBox width="100%">
        <mx:Button id="b1" label="Click Me"/>
        <mx:Button id="b2" label="Click Me, Too"/>
</mx:HBox>              


</mx:Application>




--- In [email protected], "fred44455" <fred44...@...> wrote:
>
> How can I have the button responding when it is clicked with the message : 
> "you clicked me "
> I tried but it but it does not work. 
> 
> 
> 
> 
>  import mx.controls.Alert;
> 
>         public function createHandlers(e:Event):void {
>             b1.addEventListener(MouseEvent.CLICK, submitForm);
>             b2.addEventListener(MouseEvent.CLICK, submitForm);
>         }
> 
>         private function submitForm(e:Event):void {
>             // Handle event here.
>             Alert.show("Current Target: " + e.currentTarget.id);
>             Alert.show(" You clicked me"); 
>         }
>     ]]></mx:Script>
> 
>     <mx:Button id="b1" label="Click Me"/>
> 
>     <mx:Button id="b2" label="Click Me, Too"/>
> 
> </mx:Application>
>


Reply via email to