Load the XML with the MP3 loaders defined. I'm Using a couble of inner functions to keep tabs on progress, errrors etc
public function loadStuff() : void {
LoaderMax.activate([MP3Loader]);
// only necessary once - allows XMLLoader to recognize MP3Loader's in the XML
try {
loader = new XMLLoader(_cs_samplesPath + "samples.xml", {prependURLs:_cs_samplesPath, onProgress:sampleLoadProgressHandler, onComplete:sampleLoadCompleteHandler, onError:sampleLoadErrorHandler, estimatedBytes:50000});
loader.load();
} catch(error : Error) {
trace("Load Stuff has ");
}
function sampleLoadProgressHandler(event : LoaderEvent) : void {
// trace("progress: " + event.target.progress);
}
function sampleLoadErrorHandler(event : LoaderEvent) : void {
trace("error occured with " + event.target + ": " + event.text);
}
function sampleLoadCompleteHandler(event : LoaderEvent) : void {
createSamples();
}
}
Once they are loaded I use their names from the XML and the content of the MP3Loader to do what I need
private function createSamples() : void {
var sampleXML : XML = loader.content;
var sampleloaders : XMLList = sampleXML.child("LoaderMax").child("MP3Loader");
for (var i : int = 0; i < sampleloaders.length(); i++) {
var sampleName : String = sampleloaders[i].@name;
var voiceSound : Sound = LoaderMax.getContent(sampleName);
var newPCMVoice : SiONVoice = new SiONVoice();
newPCMVoice.setPCMVoice(voiceSound);
samplerVoices.push(newPCMVoice);
samplerVoicesNames.push(String(i) + "-" + sampleName);
}
getStarted();
}
MP3Loader and imported MP3 files
in Loading (Flash)
Posted
This is what works for me.
Define Loaders in xml. Set autoPlay to false so we don't hear them play as soon as they are loaded
Load the XML with the MP3 loaders defined. I'm Using a couble of inner functions to keep tabs on progress, errrors etc
Once they are loaded I use their names from the XML and the content of the MP3Loader to do what I need