PDA

View Full Version : Disable button



RossKidd
April 28th, 2009, 07:24 AM
I have a button class which disables the current button when it is clicked, the problem is I need to restore the mouseclick event to all the other button or eventually if you work through the menu all the button will be disabled. How can I iterate through all non-clicked items and restore the clicks to the non-clicked buttons?

public function onClick(e:MouseEvent)

{


this.parent.gotoAndStop(e.target.name);
e.target.removeEventListener(MouseEvent.CLICK, onClick);


}

pensamente
April 28th, 2009, 07:34 AM
not sure if I can't figure out your problem, but let me try:

create a array to store the state of each button like:

buttonsState = [1,1,1,1,0,1];

Each button state is represented in a array position, 0 means inactive, 1 active, when you click you can know which button is inactive and restore the event, and then you have to change the array to update the current state.
Hope this makes any sense.