Global Error Handler for Flash Player 10.1 not working

﹥>﹥吖頭↗ 提交于 2019-12-01 00:35:09

I had the same issue as above - I was referencing stage.loadInfo, believing that as that references the stage, it would capture all uncaught errors. However, that doesn't work, you have to actually follow grapefukt's suggestion verbatim: On the actual base display object, place the code

loaderInfo.uncaughtErrorEvents.add...

When you try to place onto stage.loaderInfo or frame.loaderInfo, it has no effect.

In my case, I had to place it in the class that extended the base display object. Very Odd.

The docs say that:

The UncaughtErrorEvents object that dispatches the event is associated with either a LoaderInfo object or a Loader object.

Thus you must listen to the loaderInfo's uncaughtErrorEvents property of your topmost display object:

loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
Rich Sadowsky

UPDATE: I think I may know why you think this isn't working. I made the mistake of testing inside the debugger. When the debugger stopped on the runtime errors I assumed that this proved my uncaughtErrorHandler function was not working. In fact, this was in error. It's just a quirk of the debugger. The debugger will still stop as if it is an unhandled error or exception, but if you press Run again you'll see it DOES execute the error handling code. See my thread Flex 4.0/4.5 global error handling for more info.

Original response: I am looking for this same info. None of the examples in the API doc nor various blogs on the subject work for me. I've tried just loaderInfo, stage.loaderInfo, systemManager.loaderInfo... It makes no difference. I even tried all of them in a single test case! The addEventListener are being set but the uncaught errors are not firing the uncaughtErrorHandler. Argh. I have wasted far too much time on this! I've reduced it to a very simple program much like above except with all the code in the main mxml file.

How about this: can someone post a Global Error Handling example that DOES work? I'm using Flex SDK 4.1 (I've also tried with 4.5), targeting FP 10.1 (or 10.2 for 4.5), in a mx:Application-based mxml Flex project.

My thread: Flex 4.0/4.5 global error handling

You must set up the listener not to a specific view, but to the main stage object, as it's at the top of the display list (thus picking up any exception of any of its children).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!