Removing event listener from a button.

I've added a "click" event listener to a button, but I'd like to remove it once the button is clicked, so it's not active/clickable any longer. Here's the basic code:
sym.$('button').click(function(){
     //here I need to make this button not clickable any longer
Thank you.

one way...
sym.$('button').click(function(){
     //here I need to make this button not clickable any longer
     // do smething here then unbind click handler
            sym.$('button').unbind( "click" );
unbind documentation here.
hth
Darrell

Similar Messages

  • Remove event listener from loaded external swf

    I have a main movie timeline that loads an external swf. When I unload the swf from the main timeline I get an error from this:  my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, vidEnd);
    is there any way to remove the event listener from the loaded swf from the main timeline?
    THANKS!

    if you're publishing for fp 10+, use unloadAndStop() applied to your swf's loader.  that has a fair chance of solving the problem.
    if that fails, you should explicitly stop my_FLVPlybk.

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

  • Removing an event listener from buttons

    Hi.
    I´d like to know if it´s necessary to remove event listeners from buttons.
    I know it's good practice to remove event listeners when its use is over.
    But it´s necessary to remove event listeners for buttons as well?
    Thanks

    it's necessary if you want to ready your buttons for gc.

  • How to remove event listener when all the MoviClip are off the stage

    Hi i am newbie to as3,
        I am creating animation using as3 in which i duplicate the circle ten time,then pushing into an array and giving random motion. When all the duplicate object goes outside the stage then i should remove the event listener. But right now when one duplicate object goes off the stage the event listener is removed. Thanks in advance

    //---------code for creating random bubble movement------//
    var bubbleNo:Number = 10;
    var vx:Number = .3;
    var vy:Number = .5;
    var bubbles:Array = new Array();
    var bubbleRadius:Number = 9;
    var myColor:ColorTransform = this.transform.colorTransform;
    init();
    function init():void {
    for(var i:Number = 0; i<bubbleNo; i++){
              var bubble = new newBall();
    bubble.x = Math.random() * stage.stageWidth;
    bubble.y = Math.random() * stage.stageHeight;
    //bubble.color = Math.random
    //trace("bubble.x=="+bubble.x+"bubble.y=="+bubble.y);
    bubbles.push(bubble);
    myColor.color = Math.random() * 0xFFFFFF
    bubble.transform.colorTransform = myColor;
    addChild(bubble);
              addEventListener(Event.ENTER_FRAME,createBubble);
    //addEventListener(Event.ENTER_FRAME,createBubble);
    function createBubble(event:Event):void{
    for(var k:Number = bubbles.length-1; k>0; k--){
              var bubble = (newBall)(bubbles[k]);
              bubble.x += vx;
              bubble.y += vy;
              if(bubble.x - 18 > stage.stageWidth || bubble.x + 18 < 0  || bubble.y - 18 > stage.stageHeight || bubble.y + 18 < 0){
                        removeChild(bubble);
                        bubbles.splice(k, 1);
                        //trace("out"+bubbles.length);
                        if(bubbles.length <= 0 );
                                  removeBubble();
                                  trace(bubbles.length);
                                  //removeEventListener(Event.ENTER_FRAME,createBubble)
                        trace("all Bubbles cleared");
                        function removeBubble():void{
                                  removeEventListener(Event.ENTER_FRAME,createBubble)

  • Remove Event Listener : Best Practice

    This quesiton isn't really keeping me from progressing on my current project, but I was wondering what the best practice was. If I'm about to remove an item with removeChild(), should I first remove any Event Listeners that were on that object or do those get removed and cleared from memory automatically when the child is removed?
    Thanks,
    Dave

    As Kalisto mentioned, the listeners will only be removed automatically if you use weak reference when you add it:
    myObject.addEventListener(MouseEvent.CLICK, someFunction, false, 0, true);
    The true on the end specifies to use weak ref. If you don't use that (you always should) then you will have to remove it manually or it will hang around forever.
    Also, removeChild simply removes the object from the display list... it's still in memory. Set it to null if you want to truly clear it.

  • Can "netca" delete and remove a listener from a cluster from cmd line?

    We are trying to automate the shutdown, deletion and removal of a clustered listener. To date all we have been able to do is to remove it with "netca" interactively.
    Does anyone know if "netca" can use a response file or some other method to programatically remove a listener and remove it from the cluster?

    oes anyone know if "netca" can use a response file or some other method to programatically remove a listener and remove it from the cluster? I am not sure, but this is the way we followed to un-register the Listener from the cluster, and create a new one!
    1) Ensure Nodeapps is stopped on all Nodes
    2) Use the crs_unregister to remove all Listener Entries =
    crs_unregister ora.acmord1p.LISTENER_DBPROD_ORD1P.lsnr
    crs_unregister ora.acmord2p.LISTENER_DBPROD_ORD2P.lsnr
    The below command should not reflect any entry for Listener after "crs_unregister"
    command. ==
    $ srvctl config listener -n aXXXXXX2p
    $ srvctl config listener -n aXXXXXX1p
    $ crs_stat -v
    3) Once the Listener entries are removed, invoke NETCA to configure the Listeners
    4) Start the Nodeapps on all Nodes
    Check the new Listener status.
    $ srvctl config listener -n aXXXXX2p
    $ srvctl config listener -n aXXXXX1p
    $ crs_stat -v << This should show LISTENER ONLINE >>

  • Removing event listener on ROLL_OUT

    I'm trying to build a scrolling thumbnails from scratch for my first time and i can get the thumbs to scroll when the mouse rolls over the scroll arrow, but i can't get it to stop scrolling once the mouse rolls out. here's what I have if someone can help point out where the function should go.
    leftscroll_mc.addEventListener(MouseEvent.ROLL_OVER, scrollLeft);
    function scrollLeft(e:MouseEvent):void {
    addEventListener(Event.ENTER_FRAME, goLeft);
    function goLeft(e:Event):void {
    grds1_mc.x+=6;
    grds2_mc.x+=6;
    grds3_mc.x+=6;
    grds4_mc.x+=6;
    grds5_mc.x+=6;
    grds6_mc.x+=6;
    grds7_mc.x+=6;
    grds8_mc.x+=6;
    grds9_mc.x+=6;
    grds10_mc.x+=6;
    grds11_mc.x+=6;
    leftscroll_mc.addEventListener(MouseEvent.ROLL_OUT, lremoveFast);
    function lremoveFast(e:MouseEvent):void {
    leftscroll_mc.removeEventListener(Event.ENTER_FRAME, scrollLeft);
    I've tried moving the entire roll_out function all over the place but I would get errors not being able to find lremoveFast but either way I can't get it to funciton

    The first thing you need to do is to move all of those functions outside of the function they are in.  You should not nest named functions because they do not compile.  When you assign the ENTER_FRAME listener, to remove it you must remove it from where it is added, and be sure you're removing the one added--you have things jumbled up there--wrong target, wrong listener.  Another thing you could do is reduce your code by using  a loop for all those similarly named movieclips.
    leftscroll_mc.addEventListener(MouseEvent.ROLL_OVER, scrollLeft);
    leftscroll_mc.addEventListener(MouseEvent.ROLL_OUT, lremoveFast);
    function scrollLeft(e:MouseEvent):void {
         this.addEventListener(Event.ENTER_FRAME, goLeft);
    function lremoveFast(e:MouseEvent):void {
        this.removeEventListener(Event.ENTER_FRAME, goLeft);
    function goLeft(e:Event):void {
         for(var i:int = 1; i<12; i++){
              this["grds"+String(i)+"_mc"].x+=6;

  • [iOS][Playlists] A quick "Remove this song from playlist" button

    So many times I've been listening to what I thought was a pretty awesome playlist that I've made, only to hit a track that just sucks! What was I thinking adding that to my list of best songs?! It would be great to have a quick way of deleting the offending and embarassing item from the playlist so that it can no longer bother anybody! Perhaps a button in the (...) drop-down menu, below the "Add to Playlist" button, and it might read "Remove from this Playlist".  I think that would be a pretty well-used feature on my spotify app!

    Updated: 2015-07-14Hello and thanks for the feedback!
    A similar idea has also been suggested here:
    https://community.spotify.com/t5/Live-Ideas/Delete-song-from-playlist-in-Now-playing-menu-Mobile/idi-p/4953 and
    https://community.spotify.com/t5/Live-Ideas/iOS-Remove-Song-from-Playlist-in-Option-Menu-quot-quot/idi-p/1013838
    Add your kudos and comments there please! ;)

  • Remove key listener from scroller

    I have some key events that I need to listen to when the user presses left, right, up down. Idealy I would add the listener to my Canvas which is where something will visualy change on key press. Problem is that this canvas is in a JScrollPane and can't recieve key events from there, so I added the listener to the JScrollPane instead. This works fine except when scrollbars are present, when this happens the scrollbars scroll on keypress instead of executing my event. Is there a way to disable keyboard scrolling or any way to recieve keyboard events while the JScrollPane has focus.

    This [url http://forum.java.sun.com/thread.jsp?forum=57&thread=450711]thread might help. It shows how to attach an Action to a KeyStroke for a given component.

  • Removing Events, Projects from Library manually

    Hi
    Has anyone removed either Events or Projects from the Library manually (deleting from package contents on drive)?
    Any reason there could be a problem?
    best
    elmer

    Ah, so you do have experience of what can go wrong. That's different. I just posted a discussion about my experiment.
    You say do it inside, I see no way to do that. Not without copying the project''s media along with the project. And that happens with external consolidation too right. If I consolidate an event (projects only) outside FCPX, it will copy the media used in those projects also. I don't want to copy the original clips that constitute the 40+minutes of the first half or the 45 minutes I've reached with more to do of the second half.
    The reason I would do it is that I'm having lots of twirling color ball and drop down windows saying projects that are unneeded are loading. Into the ram. I'm trying to figure out how to lessen the ram's load and it always seems to load old projects. Editing segments of a feature-length doc, I often experiment where I see a possible different route, and if I'm going to make more than a couple changes, or I'm not sure if I am, I duplicate the project and continue working. I don't think that's uncommon.
    In FCP and earlier versions of FCPX you could easily get past the problem by: in FCP, duplicating the project and deleting old sequences (you could always copy back in), or in earlier FCPX, removing specific event and project folders from Final Cut Events and Final Cut Projects folders (you could always return).
    THANKS for taking the time to help, I very much appreciate it.
    best
    elmer

  • Remove Recent Item From Home Button

    How can i remove list or any item appears in recent tab when i double click home button?

    If melimata doesn't have a computer, then she could move the photographs to an online storage medium such as Dropbox. It'll be possible to permanently store photographs in iCloud when iCloud Photo Library is launched in the near future.

  • Removing Keyborard Listener from ComboBox

    I have a ComboBox created and when I select the comboBox and
    press the down/up keyboard it moves from next/previous item in the
    comboBox list. I want to remove this feature. down/up/right/left
    keyboards control a movieclip but when this comboBox is selected it
    doesn't work because of this ComboBox.
    Thanks in advance.

    Please help me!!!

  • Removing the Listener

    Hello all,
    i Came across a class java.awt.AWTEvent,+
    there i saw the method,
    final void removeSourceEvents(java.lang.Object, boolean);
    how can i use this method to removeListeners to the various components i have set like
    Button b=new Button();
    b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
    Some code
    Please Help me to remove the listener after some action.
    I do not want the button to be disabled,instead i want to add and remove the listeners .
    thanks in advance
    Regards
    INFLIATOR

    getRequest wrote:
    myComponent.removeABClistener
    so will it be
    b.removeActionListener() ? ? ?If you pass your listener as Parameter, you may just do so. Why don't you try it?
    I do not understand why you want to remove the listener from your button when it is pressed. It seems to me like blasting the bridge you are walking on. well it will work though.

  • Removing a Button Event Listener on a Specific Frame and Reactivating it on Next Frame

    Hi , i am trying to develop a Slideshow where Next Button needs to behave in a certain way on a specific Frame , lets say a Specific Condition is met only then Next Button would work , I have been able to achieve that but problem is the Button Retains its Event Listener even on the next Frame , whereas  i have already included removeEventListener on the next frame with a new Function for the button , but its doesnt take it like that.
    Can anyone help please ?

    Hello Ned,
    I have fixed the issue with few Frame , but where we have the conditions to be met on two consecutive frames , I am not able to achieve that.
    here is the Code on my first Frame.
    FRAME1
    stop();
    slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
    mc_prog.width = 0;
    //LIBRARIES TO BE IMPORTED ///////////////////////////////////////////////////////////
    import flash.events.MouseEvent;
    //VARIALBLES INITIATED
    var score:Number = 0;
    var questions:Number = 0;
    var qtotal:Number = 11;
    var attempt:Number = 0;
    var indexframe:int;
    indexframe = this.totalFrames - 1;
    var notes:Array = new Array();
    var count:int;
    count = 0;
    var backcounter:int;
    backcounter = 0;
    var count2:int;
    count2 = 0;
    var backcounter2:int;
    backcounter2 = 0;
    var count3:int;
    count3 = 0;
    var backcounter3:int;
    backcounter3 = 0;
    // MOVIE CLIPS INITITATED ////////////////////////////////////////////////////////////////
    var volbutton1:volcontrol;//VOLUME BUTTON ROLLOVER MOVIE CLIP
    volbutton1 = new volcontrol();
    var clist:courselist;//VOLUME COURSE LIST ROLLOVER MOVIE CLIP
    clist = new courselist();
    var pop1:Mc_slide9 = new Mc_slide9;
    pop1 = new Mc_slide9;
    var pop2:Mc_slide13 = new Mc_slide13;
    pop2 = new Mc_slide13;
    var pop3:Mc_slide17 = new Mc_slide17;
    pop3 = new Mc_slide17;
    //BUTTONS INITIATED
    btn_nxt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);//NEXT SLIDE BUTTON
    btn_bck.addEventListener(MouseEvent.CLICK, backbtn);//BACK BUTTON
    btn_loc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage); //LIST OF COURSES BUTTON
    btn_notice1.addEventListener(MouseEvent.CLICK, loadnotice1);
    pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
    btn_notice2.addEventListener(MouseEvent.CLICK, loadnotice2);
    pop2.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn2);
    btn_notice3.addEventListener(MouseEvent.CLICK, loadnotice3);
    pop3.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn3);
    //VOLUME BUTTON ROLL OVER FUNCTION EVENT LISTENERS ///////////////////////////////////////
    btn_vol.addEventListener(MouseEvent.ROLL_OVER,vol);
    btn_vol.addEventListener(MouseEvent.ROLL_OUT,volout);
    btn_loc.addEventListener(MouseEvent.ROLL_OVER,coursel);
    btn_loc.addEventListener(MouseEvent.ROLL_OUT,corlist);
    // FUNCTIONS INITIATED /////////////////////////////////////////////////////////////////
    function fl_ClickToGoToNextFrame(event: MouseEvent): void
      nextFrame();
    function backbtn(event:MouseEvent):void{
       prevFrame();
    function fl_ClickToGoToWebPage(event: MouseEvent): void {
      navigateToURL(new URLRequest("https://www.onlineinduction.com/fmgl/courselist.php?ist=2&type=Vendor Employee Inductions"), "_self");
    //VOLUME BUTTON ROLLOVER EFFECT FUNCTION
    function vol(e:MouseEvent):void
      addChild(volbutton1);
      //popup_instance.width = 675;
      //popup_instance.height = 300;
       if(this.currentFrame == 2)
        volbutton1.x = 150;
        volbutton1.y = 528;
       else{
        volbutton1.x = 278;
        volbutton1.y = 528;
      function volout (e:MouseEvent):void {
        removeChild(volbutton1);
       function coursel(e:MouseEvent):void {
       addChild(clist);
        if(this.currentFrame == 2)
         clist.x = 85;
         clist.y = 532;
        else if(this.currentFrame == 5){
         clist.x = 115;
         clist.y = 325;
        else{
         clist.x = 175;
         clist.y = 532;
      function corlist (e:MouseEvent):void {
        removeChild(clist);
    function loadnotice1(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
      if ( count == 1 && stage.contains(pop1))
       removeChild(pop1);
        if(count == 1)
         nextFrame();
        else
         addChild(pop1);
         pop1.x = 40;
         pop1.y = 120;
         count = 1;
      trace("Counter Value:" + count);
    function loadnotice2(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
      if ( count2 == 1 && stage.contains(pop2))
       removeChild(pop2);
        if(count == 2)
         nextFrame();
        else
         addChild(pop2);
         pop2.x = 40;
         pop2.y = 120;
         count2 = 1;
      trace("Counter Value:" + count);
    function loadnotice3(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
      if ( count3 == 1 && stage.contains(pop3))
       removeChild(pop3);
        if(count == 3)
         nextFrame();
        else
         addChild(pop3);
         pop2.x = 40;
         pop2.y = 120;
         count2 = 1;
      trace("Counter Value:" + count);
    function nextframe9(event: MouseEvent): void
        if(count == 1 && stage.contains(pop1) )
           removeChild(pop1);
        if(count == 1)
         nextFrame();
        else
         addChild(pop1);
         pop1.x = 40;
         pop1.y = 120;
         count = 1;
    function nextframe13(event: MouseEvent): void
        if(count2 == 1 && stage.contains(pop2) )
           removeChild(pop2);
        if(count2 == 1)
         nextFrame();
        else
         addChild(pop2);
         pop2.x = 40;
         pop2.y = 120;
         count2 = 1;
    function nextframe17(event: MouseEvent): void
        if(count3 == 1 && stage.contains(pop3) )
           removeChild(pop3);
        if(count3 == 1)
         nextFrame();
        else
         addChild(pop3);
         pop3.x = 40;
         pop3.y = 120;
         count3 = 1;
    function backbtnscript1(event:MouseEvent):void
       if(stage.contains(pop1) )
          removeChild(pop1);
          backcounter = 1;
          trace("back" + backcounter);
          prevFrame();
    function unloadbtn1 (e:MouseEvent):void {
      removeChild(pop1);
    function backbtnscript2(event:MouseEvent):void
       if(stage.contains(pop2) )
          removeChild(pop2);
          backcounter2 = 1;
          trace("back" + backcounter2);
          prevFrame();
    function unloadbtn2 (e:MouseEvent):void {
      removeChild(pop2);
    function backbtnscript3(event:MouseEvent):void
       if(stage.contains(pop3) )
          removeChild(pop3);
          backcounter3 = 1;
          trace("back" + backcounter3);
          prevFrame();
    function unloadbtn3 (e:MouseEvent):void {
      removeChild(pop3);
    //SLIDE COUNTER
    and here is the Code on all the Frames where I need to call in specific Listeners
    FOR EXAMPLE ON FRAME 8,9,10,
    Here Is the Code ,
    FRAME 8
    stop();
    slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
    count = 0;
    backcounter = 0;
    btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
    btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
    btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
    btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
    pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
    //btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
    FRAME 9
    stop();
    slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
    //POPUP FUNCTION
    count = 0;
    btn_nxt.removeEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
    btn_bck.removeEventListener(MouseEvent.CLICK, backbtn);
    btn_bck.addEventListener(MouseEvent.CLICK , backbtnscript1);
    btn_nxt.addEventListener(MouseEvent.CLICK , nextframe9);
    btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
    FRAME 10
    stop();
    slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
    count = 0;
    backcounter = 0;
    btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
    btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
    btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
    btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
    pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
    I am repeating this Pattern on each frame set where I need these Listeners ,
    Problem is with the next one where I have two consecutive frames have different conditions to meet, any ideas how would I disable and enable listeners respectively on these frames ?
    I hope I am not confusing this very much ?;(

Maybe you are looking for