I'm feeling kind of dumb for asking, but...
I'm building a multimedia player. For now I'm only concerned with the MP3Loader portion.
Basically, I could have hundreds of MP3s which I only want to load on demand and one at a time. What is the best way to go about this?
I thought about creating a single MP3Loader and simply re-use it.
private var _mp3Loader:MP3Loader;
public function playMP3(audiofilename:String):void{
stopPrevAudio();
_mp3Loader = new MP3Loader(audiofilename, {name:"mp3", autoPlay:true, estimatedBytes:9500, onComplete:completeHandler});
_mp3Loader.addEventListener(MP3Loader.PLAY_PROGRESS, playProgress);
_mp3Loader.load();
}
private function stopPrevAudio():void{
_mp3Loader.unload(); // No sound ever plays when I do this. And still needs to remove event listeners, etc...
}
private function completeHandler(event:LoaderEvent):void{
//
}
private function playProgress(event:LoaderEvent):void{
//
}
The "unload" seems to kill the object. And creating potentially hundreds of MP3Loader objects seems like bad practice. Can someone please point me in the right direction?
I'll provide more code if needed, but wanted to keep it simple for now.
Thanks in advance...!