【问题标题】:Fade IN sound with Actionscript 3.0使用 Actionscript 3.0 淡入声音
【发布时间】:2018-10-02 20:05:14
【问题描述】:

我已经设法使用 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});

我不能做的是淡入声音。已尝试设置初始音量但无法正常工作。感谢我能得到的任何帮助。

【问题讨论】:

  • 我想知道你是如何让它淡出的,因为 SoundChannel 实际上没有 volume 属性。很可能 volume 部分被忽略,音频在 1 秒后停止。这就是为什么淡入不起作用的原因,因为淡出也不应该起作用。
  • 呵呵,对,补间应该针对channel.soundTransform,而不仅仅是通道。当您尝试淡入时您听不到任何声音的原因是声音在您的第一个补间完成时停止 - 您必须在淡入之前再次播放()它
  • 感谢您的回复!我只是自己想通了。不知道为什么在没有“var trans:SoundTransform = new SoundTransform(X, X);”的情况下淡出效果。如果未定义音量,它可能将 value = 1 设置为默认值?

标签: actionscript-3 flash audio fade


【解决方案1】:
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();
}

【讨论】:

    猜你喜欢
    • 2017-06-07
    • 1970-01-01
    • 2011-01-21
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    • 1970-01-01
    相关资源
    最近更新 更多