actionscript-3 - 使用Actionscript 3.0淡入声音

标签 actionscript-3 flash audio fade

我已经使用以下代码和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/

相关文章:

actionscript-3 - mx.collections 不见了? Flex4 中的 ArrayCollection() (Flash Builder 4)

javascript - ActionScript 3 - ArgumentError : Error #2025: The supplied DisplayObject must be a child of the caller

audio - OpenAL 设备、缓冲区和上下文关系

c# - 在 MemoryStream 中拆分 mp3 音频的正确方法是什么?

actionscript-3 - ActionScript/AIR - 在运行时确定设备配置文件?

iphone - 在没有 iTunes/越狱/AppleDev 的情况下在 iOS 上测试 Flash 游戏?

actionscript-3 - 如何检查swf在AS3中是否已经失焦

jquery - 如何在所有主流浏览器的 Flash 顶部显示 Javascript 导航菜单

apache-flex - 有没有办法覆盖 ActionScript 运算符,特别是我想覆盖等号运算符

python - Python获取语音转文本语音音频数据