我正在使用此代码加载和卸载按钮的外部swf。当我点击按钮,swf加载,当我再次点击按钮swf卸载,但声音仍然存在,只是swf屏幕消失。
请更正此代码,我希望swf完全卸载。
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"));
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;
}
答案 0 :(得分:0)
如果您可以访问加载的swf中的代码,则可以添加Event.UNLOAD
侦听器。在事件处理程序中,您可以进行一些清理:
Stage
)这样,卸载应该顺利和轻松。