Define a handler function, register it for click event of the Button control : Button Event « Components « Flex






Define a handler function, register it for click event of the Button control

Define a handler function, register it for click event of the Button control
        

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    initialize="createListener()">
    <mx:Script>
    import mx.controls.Alert;
    
    private function createListener():void {
        b1.addEventListener(MouseEvent.CLICK, myClickHandler, false, 0);
    }
    private function myClickHandler(e:MouseEvent):void {
        Alert.show("The button was clicked");
    }
  </mx:Script>
    <mx:Button label="Click Me" id="b1" />
</mx:Application>

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.Check to see if button has certain type of eventCheck to see if button has certain type of event
2.Embed calculation logic into Button click eventEmbed calculation logic into Button click event
3.Add event listener function to Button with ActionScriptAdd event listener function to Button with ActionScript
4.Specify a listener function for the Button control's click eventSpecify a listener function for the Button control's click event
5.Access button id that triggered the eventAccess button id that triggered the event
6.Add addEventListener() inline with Button's initialize propertyAdd addEventListener() inline with Button's initialize property
7.Dispatch a Button control's click event, without clicking a ButtonDispatch a Button control's click event, without clicking a Button
8.When clicking a Button control, the Button control dispatches a click eventWhen clicking a Button control, the Button control dispatches a click event
9.RadioButton click event handlerRadioButton click event handler
10.itemClick event for group tells which button was selecteditemClick event for group tells which button was selected
11.Define an event listener for the Button controlDefine an event listener for the Button control
12.Link button click eventLink button click event
13.Set Button click event handler method with both ActionScript and MXMLSet Button click event handler method with both ActionScript and MXML
14.Change state in button click eventChange state in button click event
15.Button click property contains event listenerButton click property contains event listener
16.Accesses Button id that triggered the eventAccesses Button id that triggered the event
17.Use addEventListener() method to register different buttons to same handler functionUse addEventListener() method to register different buttons to same handler function
18.Set Button event handler with SetEventHandlerSet Button event handler with SetEventHandler
19.Call web service in Button click event handler
20.preinitialize, initialize, creationComplete events for Button controlpreinitialize, initialize, creationComplete events for Button control
21.Use button click event to update Label textUse button click event to update Label text
22.Button AddEventListener methodButton AddEventListener method
23.Button Click eventButton Click event
24.When a user selects a RadioButton control, Flex calls the event handler associated with that button's click eventWhen a user selects a RadioButton control, Flex calls the event handler associated with that button's click event
25.To set functionality such as a single event handler on the group, use the tagTo set functionality such as a single event handler on the group, use the <s:RadioButtonGroup> tag
26.itemClick event listener for the group can take a different action depending on which button was selecteditemClick event listener for the group can take a different action depending on which button was selected
27.Use the pause() and play() methods in event listener for two Button controls to pause or play an FLV file
28.Handle a Button's Click EventHandle a Button's Click Event
29.Delete button controls by pressing the mouse button and hold Shift keyDelete button controls by pressing the mouse button and hold Shift key
30.Specify listener function in the click attribute of the Specify listener function in the click attribute of the <mx:Button>
31.Define a function that logs the various stages of the Button control's startup life cycleDefine a function that logs the various stages of the Button control's startup life cycle