Welcome to my actionscript snippet library!

Actionscript Snips is a small repository of actionscript code that aims to save developers and designers time when developing a website.  

Load Sound


import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;

var urlRequest:URLRequest;
var sound:Sound;

function loadSound(url:String):void {
urlRequest = new URLRequest(url);
sound = new Sound();
sound.addEventListener(Event.COMPLETE, loadSoundComplete);
sound.load(urlRequest);
}

function loadSoundComplete(e:Event):void {
sound.play();
}

loadSound("sound.mp3");

0 comments:

Post a Comment