Add handlers and then remove handlers : Event Handler « Event « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Event » Event Handler 




Add handlers and then remove handlers
Add handlers and then remove handlers
            
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    initialize="createHandler(event)">
    <mx:Script>
    import mx.controls.Alert;
    private function createHandler(e:Event):void {
        b1.addEventListener(MouseEvent.CLICK, myClickHandler);
    }
    private function removeMyHandlers(e:Event):void {
        b1.removeEventListener(MouseEvent.CLICK,myClickHandler);
        b2.removeEventListener(MouseEvent.CLICK,myClickHandler);
    }
    private function myClickHandler(e:Event):void {
        Alert.show("This is a log message");
    }
  </mx:Script>
    <mx:Button id="b1" label="Click Me" />
    <mx:Button label="Click Me Too" id="b2"
        click="myClickHandler(event)" />
    <mx:Button label="Axe Listeners" id="b3"
        click="removeMyHandlers(event)" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
    
  














Related examples in the same category
1.Using event object to make event handlers more genericUsing event object to make event handlers more generic
2.Creating function and use it as event handlerCreating function and use it as event handler
3.A function returning String and use it in button event handlerA function returning String and use it in button event handler
4.Register handler function to Button controlRegister handler function to Button control
5.Remove handlerRemove handler
6.Conditional handlerConditional handler
7.Use the handler property to specify the function Argument StringUse the handler property to specify the function Argument String
8.Use the handlerFunction property to specify the functionUse the handlerFunction property to specify the function
9.Using ActionScript in MXML event handlersUsing ActionScript in MXML event handlers
10.Specify Event object as a parameter in the event handler functionSpecify Event object as a parameter in the event handler function
11.Define an event handler inline and binds a call to the handler function to the controlDefine an event handler inline and binds a call to the handler function to the control
12.Event handler functionEvent handler function
13.Parent container's click handler disables the target control after the target handles the eventParent container's click handler disables the target control after the target handles the event
14.Handler children clicked event from parent clicked eventHandler children clicked event from parent clicked event
15.Priority parameter and event handler eventPriority parameter and event handler event
16.Add itself to event handlerAdd itself to event handler
17.To use the Event object, you specify it as a parameter in the event handler functionTo use the Event object, you specify it as a parameter in the event handler function
18.Create two event handler functionsCreate two event handler functions
19.Bind a call to the handler function to the control that triggers the eventBind a call to the handler function to the control that triggers the event
20.Simple Event HandlerSimple Event Handler
21.Pass string into event handlerPass string into event handler
22.Use initialize event to register event handlerUse initialize event to register event handler
23.Event handler sequenceEvent handler sequence
24.Use SetEventHandler to set event handler to a targetUse SetEventHandler to set event handler to a target
25.Add SecurityErrorEvent.SECURITY_ERROR event handler
26.Write simple event handler code inlineWrite simple event handler code inline
27.Add event handler to ChangeWatcherAdd event handler to ChangeWatcher
28.Use itemDoubleClick event handler to display HitData informationUse itemDoubleClick event handler to display HitData information
29.Event Object HandlerEvent Object Handler
30.Define variable in click event handlerDefine variable in click event handler
31.Handler result event and fault event for ItemResponderHandler result event and fault event for ItemResponder
32.Using removeEventListener() method to remove event handlerUsing removeEventListener() method to remove event handler
33.Add and remove event handlersAdd and remove event handlers
34.Gets the value of the current target's x, y, and width properties in the focusIn event handler,Gets the value of the current target's x, y, and width properties in the focusIn event handler,
35.Define an event handler for the dragDefine an event handler for the drag
36.Creates the groups in ActionScript by using an event handlerCreates the groups in ActionScript by using an event handler
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.