Flash AS3定义声音结束时间

时间:2011-08-22 15:21:40

标签: flash actionscript-3

我想在Flash中播放声音,但只是完整声音的间隔。 例如,从10秒开始,以整个声音的15秒结束。

我知道如何设置起点,但我不知道如何设定终点。 这是我使用的代码:

var s:Sound = new Sound(new URLRequest("mp3/mysound.mp3"));  
var channel:SoundChannel = new SoundChannel();
channel = s.play(start_point);

你能帮帮我们吗?

Best,Flavio

1 个答案:

答案 0 :(得分:2)

您可以使用Sound内置的方法或属性,因此您还必须设置计时器。

var s:Sound = new Sound(new URLRequest("mp3/mysound.mp3"));  
var channel:SoundChannel = new SoundChannel();
var timer:Timer = new Timer(5000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, stopSound);
timer.start();
channel = s.play(start_point);

function stopSound(e:TimerEvent):void {
  channel.stop();
}

编辑声音文件可能同样容易获得您想要的声音片段。