Can anyone offer any advice on how to unload swfs that have been loaded into a host SWF.
For eaxmple i have my main movie and am loading an external swf into it
this works fine however when i try to close it with another button in the main movie,
I get this error message
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2cf8101 to flash.display.Loader.
at VirtualSynthPiano_fla::MainTimeline/unloadFunction()
This is my code
//button in the main movie that loads the external swf
keyboardDragMC.btBtnMC.addEventListener(MouseEvent.MOUSE_DOWN, loadPlayer);
function loadPlayer(myevent:MouseEvent):void {
var myrequest:URLRequest=new URLRequest(“organBluesPlayer.swf”);
var myloader:Loader=new Loader();
myloader.addEventListener(“UnloadMe”, unloadFunction);
myloader.load(myrequest);
stage.addChild(myloader);
}
//button in main movie that should unload the swf
keyboardDragMC.editBtnMC.addEventListener(MouseEvent.MOUSE_DOWN, unloadFunction);
function unloadFunction(event:Event):void {
Loader(event.currentTarget).unload();
}
After looking around the net this seems to be quite a common problem. Would much appreciate any advice any one could offer?
thanks
Liam.