Thursday, May 22, 2008

Streaming Sounds

One main disadvantage of sound assets is they are embedded within the final SWF file. When employing large assets, this can cause the SWF file to grow large and delay loading. Fortunately, streaming sounds are supported by ActionScript.
  1. Double click source file Application.as to edit
  2. At the bottom of function init, add this code:
    snd.loadSound("http://kevinarpe.googlepages.com/small_sample.mp3") ;
    snd.onLoad = function(success:Boolean) {
    if (success) {
    snd.start() ;
    }
    }
  3. Save the file, and the SWF file is automatically rebuilt by Eclipse. Click to hear the MP3 play after the preloader finishes.


No comments: