You should preload sounds in as3 before playing them to prevent awkward pauses while the sound effect loads for the first time. To load and play an external sound the following code suffices (in which the first line (pre)loads the file and the second line plays it). Place the first bit in your constructor function and the second in the event handler playing the sound
var sound = new Sound(new URLRequest("soundFileName.mp3")); //optional - trace error if file is not found: sound.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void{ trace(e); }); sound.play();
import the following:
import flash.media.Sound; import flash.events.IOErrorEvent; import flash.net.*;