Copy link to clipboard
Copied
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!
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
}
}
}
Copy link to clipboard
Copied
simple buttons have upState,downState and overState properties you can use to change a button's display.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
}
}
}
Copy link to clipboard
Copied
Ohhh - I misunderstood; thank you.
I'm pathetic with scripting. Let's say I have two buttons - one is called NameButton, and the other is called NameText. I want an action (hover, click, hit) to be mirrored between the two. If I hover over NameButton, I want NameText to show its hover state too, and vice versa. If I hit NameText, I want NameButton to act as if it were hit as well. I know I've butchered yourcode to an embarrassing degree - would you be willing to show me the correct syntax for that intended experience?
var buttonName: Array = Name Buttons;
var buttonStateNameButton: Array = [NameButton, NameText];
for (var i: int = 0i < NameButton.length; i++) {
buttonStateNameButton.push([NameButton.upState, NameButton.overState, NameButton.downState]); // maintains a record of states of all buttons
buttonStateNameText.push([NameText.upState, NameText.overState, NameText.downState]
NameButton.addEventListener(MouseEvent.MOUSE_OVER, ovefF);
NameText.addEventListener(MouseEvent.MOUSE_OVER, ovefF);
}
function overF(e: MouseEvent): void {
for (var i: int = 0; i < Name Button.length, i++) {
if (i != NameButton.indexOf(e.currentTarget)) {
NameButton.overState = NameText.overState; // if that's what you want
NameText.overState = NameText.overState; // if that's what you want
}
}
}
Copy link to clipboard
Copied
var buttonA:Array=[namgeButton,nameText];
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);
buttonA.addEventListener(MouseEvent.MOUSE_OUT,outF);
}
function overF(e:MouseEvent):void{
for(var i:int=0;i<buttonA.length,i++){
if(i!=buttonA.indexOf(e.currentTarget)){
buttonA.upState = buttonStateA[1]; // if that's what you want
}
}
}
function outF(e:MouseEvent):void{
for(var i:int=0;i<buttonA.length,i++){
buttonA.upState = buttonStateA[0]; // if that's what you want
}
}
Copy link to clipboard
Copied
Thank you! I will give that a shot.
Copy link to clipboard
Copied
you're welcome.