Yet another easily solvable question that i can't solve. I'm making a game, where the user needs to load a song from their own pc and play it through in flash.
The code i've written works perfectly on an actual pc, but not in the browser. If anyone can work out how i can isolate the problem or if they know the answer, i'd be very grateful.
stop();
t.addEventListener("change", output);
btn.addEventListener(MouseEvent.CLICK, playSound);
var snd:Sound = new Sound();
var error:Boolean = false;
function output(_):void
{
trace(t.text.split("\\").join("/"));
}
function playSound(song:String):void{
snd.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
var context:SoundLoaderContext = new SoundLoaderContext(5000, false);
snd.load(new URLRequest(t.text), context);
if(error == false){
snd.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);
}
}
function onLoaded(evt:Event):void{
play();
yesno.text = "yes"
}
function onIOError(evt:IOErrorEvent):void{
var error:Boolean = true;
trace("Could not load song, check the file path.");
yesno.text = "no"
}