I have an AS3 function that loads and audio file and then plays it. I have the pre-loader for the first audio file working - now I need to run the pre-load function before the 2nd audio file starts.
myMusic.addEventListener(ProgressEvent.PROGRESS, onLoadProgress2, false,0, true);
myMusic.addEventListener(Event.COMPLETE, playMusicNow, false, 0,true);
myMusic.load(soundFile, myContext); //This code works
Here is the play code:
//This code doesn't work
function receiveText1(value:String):void {
channel.stop();
channel2.stop();
songPosition = 0;
soundFile2 = new URLRequest(jsVariableValue1);
myMusic2= new Sound(); //Intstantation
myMusic2.load(soundFile2, myContext);
//need to run preloader here
soundFile2exist = null;
}
Here is my event listener and preloader:
myMusic2.addEventListener(ProgressEvent.PROGRESS, onLoadProgress, false,0, true);
myMusic2.addEventListener(Event.COMPLETE, playMusicNow, false, 0,true);
function onLoadProgress(evt:ProgressEvent):void {
progBar.alpha = .70;
prcLoaded.alpha = .70;
var pcent:Number=evt.bytesLoaded/evt.bytesTotal*100;
prcLoaded.text =int(pcent)+"%";
progBar.width = 90 * (evt.bytesLoaded / evt.bytesTotal);
}
I thought I could call
onLoadProgress(evt:ProgressEvent);
from within the function, but I'm getting an error
1084: Syntax error: expecting rightparen before colon.