Skip to main content
Inspiring
October 16, 2012
Question

How to properly disable a button after click or can an event disable itself?

  • October 16, 2012
  • 2 replies
  • 1623 views

Can I disable  MouseEvent.CLICK after I clicked it?

I am relatively new to coding and it seems to me as a mistake that an event will disable itself?

Is it ok or is it prone to some mistakes?

mainNav_buttonsGroup_mc.Products_btn_mc.addEventListener(MouseEvent.CLICK, onClick_Products_btn);

          function onClick_Products_btn(event:MouseEvent) :void {

                    gotoAndPlay("products");

                    mainNav_buttonsGroup_mc.Products_btn_mc.removeEventListener(MouseEvent.CLICK, onClick_Products_btn);

  Products_btn_timeLine.play();

                    }

The idea is that I want to disable a button after it is clicked.

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
October 16, 2012

The approach will work.  The event is not disabling itself.  The event is the occurence of the CLICK interaction.  The event listener is designated to detect that happening.  The event handler function for that listener is disabling the event listener.

Inspiring
October 16, 2012

I don't see any problems with this, as I often use the same approach and haven't had any trouble.