Mat
Mat

Reputation: 4501

AS3 deactivate (MovieClip) Buttons

I want to temporarily deactivate some movieclips that are used as buttons. Currently I don't keep track of the EventListeners that got added to these buttons. I want to be able to deactivate and reactivate them later.

myMc.mouseEnabled=false;

works, but then they are still select- and clickable using the TAB key on the keyboard.

how to prevent that?

Upvotes: 3

Views: 11094

Answers (3)

shanethehat
shanethehat

Reputation: 15570

MovieClips have a property called enabled which prevents the MovieClip featuring in the tab order. Use this is conjunction with mouseEnabled to completely disable a MovieClip.

Upvotes: 5

crooksy88
crooksy88

Reputation: 3851

Or a quick way would be to hide the movieclips when not required

myMc.visible = false;

Upvotes: 0

vulkanino
vulkanino

Reputation: 9134

In AS3 MovieClips no longer appear or behave as buttons even when they have listeners although they would work just fine when clicked or rolled over with mouse, you have to specifically enable the button mode for MovieClips to make them change cursor to hand:

buttonMC.buttonMode = true;
buttonMC.useHandCursor = true;

To disable the button completely, remove the listener for each event you want it to stop working and also disable the button mode for the MovieClip:

buttonMC.removeEventListener(MouseEvent.CLICK, onClickHandler);
buttonMC.removeEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
buttonMC.removeEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);

buttonClip.buttonMode = false;

source: http://www.parorrey.com/blog/flash-development/how-to-enabledisable-movieclips-as-buttons-in-flash-with-actionscript-3-0/

Upvotes: 0

Related Questions