gpt4 book ai didi

actionscript-3 - 衰落的声音不起作用

转载 作者:行者123 更新时间:2023-12-03 00:10:40 25 4
gpt4 key购买 nike

当我尝试使用以下功能淡入声音时出现此问题。它只是行不通,我不知道问题出在哪里。
我想在循环声音中淡出,但是什么也没发生。我很高兴能解决这个问题。提前致谢。

用于通过事件播放声音

dispatchEvent(new CustomEventSound(CustomEventSound.PLAY_SOUND, Main.SOUND_AMBIENT, false, true, false, 999999, 0, 0, setSoundVolume));

这是播放声音的功能。停止功能与此几乎相同。
public function playSound(soundName:String, isSoundTrack:Boolean = false, fadeIn:Boolean = false, fadeOut:Boolean = false,
loops:int = 1, offset:Number = 0, volume:Number = 1):void {

if (fadeIn) {
tempSoundTransform.volume = 0;
} else {
tempSoundTransform.volume = volume;

}
tempSound = sounds[soundName];

if (isSoundTrack) {
if (soundTrackChannel != null) {
soundTrackChannel.stop();
}

soundTrackChannel = tempSound.play(offset, loops);
soundTrackChannel.soundTransform = tempSoundTransform;

if (fadeIn) {
for (var i:int = 0; i < fadeInInc; i++) {
tempSoundTransform.volume += 1 / fadeInInc;
soundTrackChannel.soundTransform = tempSoundTransform;
if (tempSoundTransform.volume >= 1) {
tempSoundTransform.volume = 1;

}
}
}

} else {
soundChannels[soundName] = tempSound.play(offset, loops);
soundChannels[soundName].soundTransform = tempSoundTransform;

if (fadeIn) {
for (var i:int = 0; i < fadeInInc; i++) {

tempSoundTransform.volume += 1/fadeInInc;
soundChannels[soundName].soundTransform = tempSoundTransform;
if (tempSoundTransform.volume >= 1) {
tempSoundTransform.volume = 1;

}

trace("tempSoundTransform.volume " + tempSoundTransform.volume);
}
}

}

}

最佳答案

我认为您的问题是由“for”语句引起的。程序将等待语句结束,然后再设置值。如果要并行增加音量值,则应在ENTER_FRAME事件上执行此操作,或尝试Sounds fade in/out with ActionScript 3

关于actionscript-3 - 衰落的声音不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8795867/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com