Flash Player里播放声音

1、建立 Sound 对象用 load() 方法加载外部的 mp3 来播放;

2、让 Sound 对象监听 sampleData 事件,这样可以播放由程序动态生成的声音,例如:
下面的示例播放简单的正弦波。

var mySound:Sound = new Sound();function sineWaveGenerator(event:SampleDataEvent):void {    for ( var c:int=0; c<8192; c++ ) {        event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);        event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);    }}mySound.addEventListener(Event.SAMPLE_DATA,sineWaveGenerator);mySound.play();
Flash Player里播放声音

相关文章:

你感兴趣的文章:

标签云: