Register a single listener function (myEventHandler()) to a Button and a CheckBox : Repeater « Components « Flex






Register a single listener function (myEventHandler()) to a Button and a CheckBox

Register a single listener function (myEventHandler()) to a Button and a CheckBox
        

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="initApp()">
    <mx:Script>
    public function initApp():void {
        button1.addEventListener(MouseEvent.CLICK, myEventHandler);
        cb1.addEventListener(MouseEvent.MOUSE_DOWN, myEventHandler);
    }

    public function myEventHandler(event:Event):void {
        switch (event.currentTarget.className) {
            case "Button":
                trace("Process Button click.");
                break;
            case "CheckBox":
                trace("Process CheckBox click.");
                break;
        }
    }
  </mx:Script>
    <mx:Button label="Submit" id="button1" />
    <mx:CheckBox label="All Words" id="cb1" />
    <mx:TextArea id="ta1" text="Please enter a search term" width="200" />
</mx:Application>

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.Repeater with ModelRepeater with Model
2.Current Index in a RepeaterCurrent Index in a Repeater
3.Image source is from RepeaterImage source is from Repeater
4.Hard code data for Repeater providerHard code data for Repeater provider
5.Use Repeater component to create LabelsUse Repeater component to create Labels
6.Provide any data within the array for Repeater componentProvide any data within the array for Repeater component
7.Get Repeater current indexGet Repeater current index
8.Repeater based on Array
9.Get start index for a RepeaterGet start index for a Repeater
10.Set count and start index for RepeaterSet count and start index for Repeater
11.Get repeater itemGet repeater item
12.ArrayCollection as the data source for RepeaterArrayCollection as the data source for Repeater
13.Use Repeater to create buttons from ArrayCollectionUse Repeater to create buttons from ArrayCollection
14.Get data from current repeater itemGet data from current repeater item
15.Reference control created by RepeaterReference control created by Repeater
16.Basic Repeater whose data source is ArrayCollectionBasic Repeater whose data source is ArrayCollection
17.Adding event listener for Button in RepeaterAdding event listener for Button in Repeater
18.Static Loop with RepeaterStatic Loop with Repeater
19.Repeater is inside a MX containerRepeater is inside a MX container
20.How the count and startingIndex properties affect a Repeater componentHow the count and startingIndex properties affect a Repeater component
21.An tag repeats a RadioButton control for each product in an XML file
22.Start from Second Element in Repeater
23.Get Item RepeaterGet Item Repeater
24.Display URL from Repeater URLDisplay URL from Repeater URL
25.Use repeaters property to display the id value of the Repeater componentsUse repeaters property to display the id value of the Repeater components
26.Repeater control creates all the objects whether or not they are initially visibleRepeater control creates all the objects whether or not they are initially visible
27.Adds a second click handler to call the logAction() method, depending on CheckBox controlAdds a second click handler to call the logAction() method, depending on CheckBox control
28.Using the instanceIndices property to set the text property of a TextInput controlUsing the instanceIndices property to set the text property of a TextInput control
29.use the repeaterIndices property instead of the instanceIndices property to set the text property of a TextInputuse the repeaterIndices property instead of the instanceIndices property to set the text property of a TextInput
30.Navigate to a URLNavigate to a URL