Actionscript 3 环路as3后的音量控制

Actionscript 3 环路as3后的音量控制,actionscript-3,flash,Actionscript 3,Flash,我的代码有问题。该代码运行良好,但有一个例外,如果我按下静音按钮,动画循环,它总是返回到volume=1。它如何能够循环而不总是返回到volume=1 var mySound:Sound = new Sound(); var songURL:URLRequest = new URLRequest("Lyd/jetpass.mp3"); var channel1:SoundChannel = new SoundChannel(); var volumeAdjust:SoundTransform =

我的代码有问题。该代码运行良好,但有一个例外,如果我按下静音按钮,动画循环,它总是返回到volume=1。它如何能够循环而不总是返回到volume=1

var mySound:Sound = new Sound();
var songURL:URLRequest = new URLRequest("Lyd/jetpass.mp3");
var channel1:SoundChannel = new SoundChannel();
var volumeAdjust:SoundTransform = new SoundTransform();
mute1.addEventListener(MouseEvent.CLICK, muteLyd);
volumeAdjust.volume = 1;
mySound.load(songURL);
channel1.soundTransform = volumeAdjust;
channel1 = mySound.play();

function muteLyd(e:MouseEvent):void {
    if(volumeAdjust.volume == 1){
    volumeAdjust.volume = 0;
} 
else {
  volumeAdjust.volume = 1;
}
channel1.soundTransform = volumeAdjust;
}

刚刚发现这段代码解决了问题:

var mySound:Sound = new Sound();
var songURL:URLRequest = new URLRequest("Lyd/jetpass.mp3");
var channel1:SoundChannel = new SoundChannel();
mute1.addEventListener(MouseEvent.CLICK, muteLyd);
unmute1.addEventListener(MouseEvent.CLICK, unMuteLyd);

mySound.load(songURL);
channel1 = mySound.play();

function muteLyd(evt:MouseEvent){
    SoundMixer.soundTransform = new SoundTransform(0);
    unmute1.visible = true;
    mute1.visible = false;
}

function unMuteLyd (evt:MouseEvent){
    SoundMixer.soundTransform = new SoundTransform(1);
    unmute1.visible = false;
    mute1.visible = true;
}