Flex全局错误处理Global Error Handler代码兼容运行于低版本Flash Player
2011-01-11 09:36
399 查看
Global Error Handler是从Flash Player 10.1.x开始才加入的功能,如果将其代码运行于Flash Player
10.0.x或更低版本的FP时,swf将会出错。
那么用什么方法才能使Global Error Handler的代在Flash Player
10.1.x时能正常使用,而在低版本FP中又不使swf出错呢?
请看如下代码:
代码
P.S.
不能把.addEventListener("uncaughtError",
onUncaughtError);改成.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR,
onUncaughtError);
因为低版本FP中没有UncaughtErrorEvent,会使swf出错。
10.0.x或更低版本的FP时,swf将会出错。
那么用什么方法才能使Global Error Handler的代在Flash Player
10.1.x时能正常使用,而在低版本FP中又不使swf出错呢?
请看如下代码:
代码
private function setGlobalErrorHandler(event:FlexEvent):void{ if( !loaderInfo.hasOwnProperty("uncaughtErrorEvents") ) return; Object(loaderInfo).uncaughtErrorEvents.addEventListener("uncaughtError", onUncaughtError); function onUncaughtError(event:Event):void{ var message:String = Object(event).error.getStackTrace(); if(!message){ if(Object(event).error is Error){ message = Error(Object(event).error).message; } else if(Object(event).error is ErrorEvent){ message = ErrorEvent(Object(event).error).text; } else{ message = Object(event).error.toString(); } } } }
P.S.
不能把.addEventListener("uncaughtError",
onUncaughtError);改成.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR,
onUncaughtError);
因为低版本FP中没有UncaughtErrorEvent,会使swf出错。
相关文章推荐
- Flex全局错误处理Global Error Handler代码兼容运行于低版本Flash Player
- Flex全局错误处理Global Error Handler在AIR 2.0和Flash Player 10.1中使用
- android 程序错误处理全局处理 UncaughtExceptionHandler
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-ISAPI-4.0_32bit”在其模块
- Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容。请查看计算机的系统信息,了解是否需要 x86 (32 位)或 x64 (64 位)
- silverlight应用程序中未处理的错误代码:2104 类别:InitializeError 消息:无法下载 iis上部署Silverlight
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
- ASP.NET使用Global.asax进行全局错误处理
- IIS发布网站浏览之后看到的是文件目录 & Internal Server Error 处理程序“ExtensionlessUrlHandler-ISAPI-4.0_64bit”在其模块列表中有一个错误模块“IsapiModule” 解决方法 & App_global.asax.pduxejp_.dll”--“拒绝访问。 ”
- HTTP 错误 500.21 - Internal Server Error 处理程序“ExtensionlessUrlHandler-ISAPI-4.0_64bit”在其模块列表中有一个错误模块“IsapiModule” 解决方法
- 11.在Global的Application_Error处理错误示例
- android 程序错误处理全局处理 UncaughtExceptionHandler
- Flex全局错误处理
- HTTP 错误 500.21 - Internal Server Error处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipel
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-Integr
- 用高版本vs编译旧VC代码时,如何处理无法从“const char [10]”转换为“LPCWSTR”的错误
- HTTP 错误 500.21 - Internal Server Error处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-ISAPI-4.0_32bit”在其模块
- HTTP 错误 500.21 - Internal Server Error处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedP
- 在Global中Application_Error事件处理错误信息