Skip to main content
Participant
October 15, 2017
Answered

A button's "down" and "hit" state includes changes to other buttons

  • October 15, 2017
  • 1 reply
  • 586 views

Hi there -

I thought I remembered a simple way to cause one button to change other buttons' down and hit states - but I can't seem to make it work easily. I have a series of buttons on the stage: button A, B, C, D, and so on. I want to, effectively, link multiple buttons. So if I hit Button A, I want Buttons C, D, and Q to change their states to their hit states. If I roll over button A, I want those buttons to change to their rollover states.

Is there a simple way to get that done?

Thank you in advance for any help you can offer!

This topic has been closed for replies.
Correct answer kglad

again, use those button states.  eg,

var buttonA:Array=[you buttons];

var buttonStateA:Array=[];

for(var i:int=0i<buttonA.length;i++){

buttonStateA.push([buttonA.upState,buttonA.overState,buttonA.downState]);  // maintains a record of states of all buttons

buttonA.addEventListener(MouseEvent.MOUSE_OVER,ovefF);

}

function overF(e:MouseEvent):void{

for(var i:int=0;i<buttonA.length,i++){

if(i!=buttonA.indexOf(e.currentTarget)){

buttonA.upState = buttonA.overState;  // if that's what you want

}

}

}

1 reply

kglad
Community Expert
Community Expert
October 15, 2017

simple buttons have upState,downState and overState properties you can use to change a button's display.

Participant
October 15, 2017

Thank you! Yes, I understand how to make one button look different in up, down and over states. But my question is how I can make one button make another button's state change as well as its own.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 15, 2017

again, use those button states.  eg,

var buttonA:Array=[you buttons];

var buttonStateA:Array=[];

for(var i:int=0i<buttonA.length;i++){

buttonStateA.push([buttonA.upState,buttonA.overState,buttonA.downState]);  // maintains a record of states of all buttons

buttonA.addEventListener(MouseEvent.MOUSE_OVER,ovefF);

}

function overF(e:MouseEvent):void{

for(var i:int=0;i<buttonA.length,i++){

if(i!=buttonA.indexOf(e.currentTarget)){

buttonA.upState = buttonA.overState;  // if that's what you want

}

}

}