从父 swf 卸载 swf
所以我将一个 swf 加载到另一个 swf 中,就像这样
CorrectURL 是我的外部 swf 变量
function startLoad(){
var mRequest:URLRequest = new URLRequest(correctURL.toString());
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event) {
var gmc:MovieClip = new MovieClip();
gmc.x = 266;
gmc.y = 67;
addChild(gmc);
gmc.addChild(loadEvent.currentTarget.loader);
}
但是当我想用另一个 swf 替换它时,我正在努力卸载该死的东西。
我正在尝试的代码是这个
function closeAllStreams(e:Event) {
e.currentTarget.loader.unloadAndStop();
gmc = null;
gmc.removeChild(e.currentTarget.loader);
trace("unloaded");
}
mLoader.contentLoaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);
我只是运气不好,因为我仍然可以听到上面的旧声音。
我也不想访问加载的 swf 的变量,否则我就作弊哈哈。
谢谢
So I loaded a swf into another swf like so
correctURL being my external swf variable
function startLoad(){
var mRequest:URLRequest = new URLRequest(correctURL.toString());
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
var gmc:MovieClip = new MovieClip();
gmc.x = 266;
gmc.y = 67;
addChild(gmc);
gmc.addChild(loadEvent.currentTarget.loader);
}
But i'm struggling to unload the damn thing when I want to replace it with another swf.
The code i'm trying is this
function closeAllStreams(e:Event) {
e.currentTarget.loader.unloadAndStop();
gmc = null;
gmc.removeChild(e.currentTarget.loader);
trace("unloaded");
}
mLoader.contentLoaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);
I'm just not having any luck as I can still hear the old sound over the top.
I don't want to access the loaded swf's variables either or i'd just cheat haha.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,unloadAndStop() 仅适用于 Flash-Player 10,然后您不需要将 null 分配给加载器引用,此方法会自行完成。 之后被调用
您的 closeAllStreams 方法将在此语句e.currentTarget.loader.unloadAndStop();
或者
e.currentTarget.loader.unload();
因此最好不要在卸载事件调度程序中调用它,即在您的情况下调用 closeAllStreams 。
Well, unloadAndStop() will work with only Flash-Player 10 and then you dont need to assign null to loader reference, this method does itself. Your closeAllStreams method will be called after this statement
e.currentTarget.loader.unloadAndStop();
OR
e.currentTarget.loader.unload();
so its better not to call it inside the unload Event dispatcher i.e closeAllStreams in your case.
无论如何,这是一个问题:
我需要解释为什么吗?
Well this is a problem anyway:
Do I need to explain why