第二次重新加载 SWF 时出现错误

发布于 2024-11-06 09:44:02 字数 2188 浏览 1 评论 0原文

我在重新加载 SWFS 时遇到一个奇怪的问题。 我从加载我的 SWF 开始:

var req:URLRequest = new URLRequest( "RegionalIntro.swf" ); 
req.method = URLRequestMethod.POST; 
req.data = true; // POST requests require non-null data 

introSWF = new Loader();
introSWF.load(req);
addChild(introSWF);

然后一旦完成我就卸载:

removeChild(introSWF);
introSWF.unloadAndStop(true);

现在,当我想重新加载 SWF 时,我再次运行第一段代码,我收到此错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

我无法弄清楚为什么我会得到第二个它加载的时间,而不是第一次。应该只是一样的吧? 这是在 Windows Projector .exe 文件内完成的,它将作为信息亭应用程序运行。

编辑:

at com.company.THPassport.exRegional::exRegionalIntro/skipTablet()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.company.THPassport.exRegional::exRegionalLoader/userLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.company.THPassport.utilities.DB::user/loadUserData()
at com.company.THPassport.utilities.DB::user/checkExistingUserLoadedXML()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

据我所知,它从这里得到一个错误:

currentUser = e.data;

maxspeechB.parent.removeChild(maxspeechB);
maxspeechA.parent.removeChild(maxspeechA);
wallstageA.parent.removeChild(wallstageA);
tabletfalls.parent.removeChild(tabletfalls);
tabletvanishes.parent.removeChild(tabletvanishes);

wallfills.alpha = 0;
    if (currentUser.getCompleteAreas() == 1) {
        wallfills.gotoAndStop(40);
    } else if (currentUser.getCompleteAreas() == 2) {
        wallfills.gotoAndStop(80);
    } else if (currentUser.getCompleteAreas() == 3) {
        wallfills.gotoAndStop(120);
    }
wallstageB.alpha = 1;
Tweener.addTween(wallfills,{  alpha:1, time:1, transition:  "linear", onComplete:dropSignpost});

我无法弄清楚为什么它第一次有效,但当它重新加载时它不起作用?

EDIT2:情节变厚,我可以通过用 try/catch 块包围堆栈跟踪顶部函数中的所有代码来捕获错误。我跟踪错误,结果是一样的,奇怪的是所有代码都按预期执行。一切正常并抛出错误......非常奇怪!我不想就这样离开它而不找出它为什么这样做......

I'm having an odd issue with reloading SWFS.
I start of with loading my SWF:

var req:URLRequest = new URLRequest( "RegionalIntro.swf" ); 
req.method = URLRequestMethod.POST; 
req.data = true; // POST requests require non-null data 

introSWF = new Loader();
introSWF.load(req);
addChild(introSWF);

Then once I'm finished I unload:

removeChild(introSWF);
introSWF.unloadAndStop(true);

Now when I want to reload the SWF I run the first bit of code again I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I cant work out why I'd get that the second time it loads and not the first. It's supposed to just be the same?
This is being done inside Windows Projector .exe file, it's going to run as a kiosk application.

EDIT:

at com.company.THPassport.exRegional::exRegionalIntro/skipTablet()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.company.THPassport.exRegional::exRegionalLoader/userLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.company.THPassport.utilities.DB::user/loadUserData()
at com.company.THPassport.utilities.DB::user/checkExistingUserLoadedXML()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

As far as I can see it's getting an error from here:

currentUser = e.data;

maxspeechB.parent.removeChild(maxspeechB);
maxspeechA.parent.removeChild(maxspeechA);
wallstageA.parent.removeChild(wallstageA);
tabletfalls.parent.removeChild(tabletfalls);
tabletvanishes.parent.removeChild(tabletvanishes);

wallfills.alpha = 0;
    if (currentUser.getCompleteAreas() == 1) {
        wallfills.gotoAndStop(40);
    } else if (currentUser.getCompleteAreas() == 2) {
        wallfills.gotoAndStop(80);
    } else if (currentUser.getCompleteAreas() == 3) {
        wallfills.gotoAndStop(120);
    }
wallstageB.alpha = 1;
Tweener.addTween(wallfills,{  alpha:1, time:1, transition:  "linear", onComplete:dropSignpost});

What I can't work out is why that works the first time, but when it's reloaded it doesn't work?

EDIT2: The plot thickens, I can catch the error by surrounding all of the code in the function at the top of the stack trace with a try/catch block. I trace the error and its the same, the weird thing is all the code executes as expected. All works fine and throws an error ... very odd! I'd hate to leave it like this without finding out why it's doing it though ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

知你几分 2024-11-13 09:44:02

尝试向 loader.contentLoaderInfo 添加完整的事件侦听器,并执行 loader.load 下面的所有操作(如 addChild(introSWF);)事件监听处理程序。即使不需要,它也可以帮助您防止出现尝试使用尚未加载的对象的情况。

Try to add a complete event listener to the loader.contentLoaderInfo and do everything below loader.load (like addChild(introSWF);)in the event listener handler. Even if not required, it helps you prevent the situation in which you are trying to use an object that hasn't load yet.

酒几许 2024-11-13 09:44:02

Ben - 该错误还有第二行吗?它可能会告诉您错误是由“RegionalIntro.swf”引发的,而不是您的包装器 swf。

该 SWF 中可能发生了一些与时间相关的事情。换句话说 - 它可能会利用一些需要在调用之前加载/初始化的资源,有时,它还没有准备好。

Ben - is there a second line to that error? It might tell you that the error is thrown by the "RegionalIntro.swf", not your wrapper swf.

It's possible that something's going on in that SWF that's timing related. In other words - it might utilize some asset that needs to be loaded/initialized before it's called, and sometimes, it isn't ready yet.

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