7 Replies Latest reply on Dec 20, 2011 7:42 AM by kglad

    need help playing sound via AS3

    complexity Level 1

      Hi all,

       

      First time I have tried playing a sound through AS3. I found an example from kirupa, but for whatever reason I can not get it to play the sound. I'm not getting any errors etc, and I have my .wav file inside the same directory as my .fla/.swf I have tried playing from inside the flash pro interface and from a personal webpage server.

       

      Is there something that I am missing? I just have a action layer with the below code inside the first from of the movie.

       

       

      var soundClip:Sound;


      function init() {

      soundClip = new Sound();

      soundClip.load(new URLRequest("mysound.wav"));

      soundClip.addEventListener(Event.COMPLETE, soundLoaded);

      soundClip.addEventListener(ProgressEvent.PROGRESS, soundLoading);

      }

      init();

       

      function soundLoaded(e:Event) {

      soundClip.play();

      }

       

      function soundLoading(e:ProgressEvent) {

      // preloader information goes here

      }

       

       

       

      Any help would be great