主页 > 数码科技 > 办公设备 > 正文

Flash Player里播放声音的方法

[作者:toruo]
2014-10-22 15:37

     如何在Flash Player里播放声音

  在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里播放声音的方法的介绍,希望对您有所帮助!

猜你喜欢

相关内容

推荐阅读

加载中...
没有更多了
X