1

Say I have two buttons, green and red. How do I make it so that when the green button is clicked once, it stays red until it is clicked again? I want to make a button to mute and unmute music. I am using SoundChannel to play my music i.e.

public var intro:IntroSound = new IntroSound();
public var soundControl:SoundChannel = new SoundChannel();
soundControl = intro.play(0, 100);

Thanks.

Liam
  • 65
  • 10
  • 1
    I think you have exact answer here: http://stackoverflow.com/questions/560490/flash-toggle-button – Ivan Chernykh May 25 '13 at 08:25
  • I'm not too sure how to apply this to my game. The button I want to apply it to is a button called `togglemusicBtn` which is inside my `menuMain` movieclip – Liam May 25 '13 at 09:01
  • 1
    So you need to learn about calling an objects inside another objects – Ivan Chernykh May 25 '13 at 09:50

1 Answers1

0

Put them in a container an toggle visibility of the top (green) Button! Im assuming u have the buttons instantiatet, im calling them greenButton and redButton.

var container:Sprite = new Sprite();
container.addChild(redButton);
container.addChild(greenButton);

container.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
    greenButton.visible = !greenButton.visible; // toggle visibility of green button
    //and do whaterver u need on click
}
M4tchB0X3r
  • 1,531
  • 1
  • 15
  • 28