i am using this code for load and unload an external swf
for a button ,
when i click on button , swf loads and when again i click on button
swf unloads but still sound exist and just swf screen disappeare
please correct this code, i want swf complete unload,
thanks alot
Code:
printer.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
var fl_Loader:Loader;
//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
if(fl_ToLoad)
{
fl_Loader = new Loader();
addChild(fl_Loader);
fl_Loader.load(new URLRequest("quiz.swf"));
fl_Loader.addEventListener("UnloadVideo", unloadFunction)
function unloadFunction(event:Event):void
{
Loader(event.currentTarget).unloadAndStop();
}
printer.x=100;
printer.y=100;
}
else
{ fl_Loader.unloadAndStop();
removeChild(fl_Loader);
fl_Loader = null;
printer.x=155;
printer.y=334;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad = !fl_ToLoad;
}