我已经使用以下代码和GreenSock插件设法淡出了声音:
import com.greensock.TweenLite;
import com.greensock.TweenMax;
var snd = new buller();
var channel:SoundChannel = snd.play(0,999);
TweenMax.to(channel, 1, {volume:0, onComplete:snd.stop});
我无法做的是逐渐减弱声音。尝试设置初始声音级别,但无法使其正常工作。感谢我能得到的任何帮助。
最佳答案
var snd = new buller();
var channel:SoundChannel = new SoundChannel();
var St::SoundTransform = new SoundTransform();
var TimerFade:Timer = new Timer(1,100);
//set the initial sound volume
St.volume = 1;
//play the sound
channel = snd.play(0,0,St);
//Fade in/out the sound
TimerFade.addEventListener(TimerEvent.TIMER,VolumeHandler);
TimerFade.addEventListener(TimerEvent.TIMER_COMPLETE,StopSound);
TimerFade.start();
private function VolumeHandler(e:TimerEvent):void{
var Lastpos:Number = channel.position;
channel.stop();
St.volume -= 0.1;
channel = snd.play(Lastpos,0,St);
}
private function VolumeHandler(e:TimerEvent):void{
channel.stop();
}
关于actionscript-3 - 使用Actionscript 3.0淡入声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49969864/