±¾ÎĽéÉÜÔÚflashÎĵµÖÐǶÈëÒôƵÎļþµÄÁ½ÖÖ·½·¨£¬Ê¹Æä¿ÉÒÔÔÚ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();
|