6 Replies Latest reply on Mar 21, 2011 5:52 PM by cablish

    How to removeEventListener for new event?

    cablish

      examples:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            creationComplete="init();">
      <fx:Script>
        <![CDATA[
         public function init():void {
          addEventListener("cEvent", addEventHandler);
         }
        
         private function addEventHandler(e:Event):void {
          removeEventListener("cEvent",removeEventHandler);
          mx.controls.Alert.show("click");
         }
        
         private function removeEventHandler(e:Event):void {
          mx.controls.Alert.show("remove");
         }
        
         private function clickHandler(e:Event):void {
          dispatchEvent(new Event("cEvent"));
         }
        ]]>
      </fx:Script>
      <s:Button lable="click" click="clickHandler(e)"/>
      </s:Application>

       

      Everyone tall me please!