How to completely stop and unload external loaded SWF sounds in AS3

actionscript-3externalflashloader

I have created a flash player that loads external swfs and control them through stop, play, frwd buttons. the external swf is added on next previous buttons click using loader class.

to remove the preiously added SWF and add new one I use the following code

l.unloadAndStop();

l.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);

l.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadHandler);

l.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loadError);

var Request:URLRequest =  new URLRequest(xmlData.Page[Current_Page_No].URL[0]);

l = new Loader();

l.load(Request);

l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,     loadProgress,false,0,true);

l.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler,false,0,true);

l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);

every thing works fine as loading complete before I click the next button, I face an issue when I click next quickly before loading the previous content completed.
the loader seems to continue loading the previous content and add its sound to stage, the sounds don't seem to stop even though its not within the current SWF. I can't simply stop all sounds because I'll have other SWFs with sound. and nothing seems to work with sound stream even unloadAndStop please help.

Best Answer

To stop all sounds you can try SoundMixer.stopAll(); before you call your load(), and maybe even before l.unloadAndStop(). I've never used it for loaded swfs but it's worth a try.

Related Topic