AS3 Loading and Playing an External MP3 File


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import flash.media.Sound;
  2. import flash.media.SoundChannel;
  3. import flash.net.URLRequest;
  4.  
  5. var snd:Sound = new Sound();
  6. var channel:SoundChannel = new SoundChannel();
  7. snd.load(new URLRequest("song.mp3"));
  8. snd.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
  9. function onComplete(evt:Event):void {
  10. channel = snd.play();
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.