1

假设我有两个按钮,绿色和红色。如何使它在单击一次绿色按钮时保持红色,直到再次单击它?我想制作一个按钮来静音和取消静音音乐。我正在使用 SoundChannel 播放我的音乐,即

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

谢谢。

4

1 回答 1

0

将它们放入容器中,以切换顶部(绿色)按钮的可见性!我假设你有按钮实例,我称它们为 greenButton 和 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
}
于 2013-05-25T12:03:06.893 回答