从父 swf 卸载 swf

发布于 2024-09-24 06:06:48 字数 1081 浏览 1 评论 0原文

所以我将一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮是我掰弯的 2024-10-01 06:06:48

好吧,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.

赴月观长安 2024-10-01 06:06:48

无论如何,这是一个问题:

gmc = null; 
gmc.removeChild(e.currentTarget.loader); 

我需要解释为什么吗?

Well this is a problem anyway:

gmc = null; 
gmc.removeChild(e.currentTarget.loader); 

Do I need to explain why

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文