Flex FlashPlayer插件非调试版本不报错问题处理

本文探讨了Flash Player插件中可调试与不可调试版本的区别,并针对不可调试版本在Flex应用中可能遇到的问题提出了三种解决方案。重点介绍了Flex全局错误处理机制及其应用实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:

FlashPlayer插件对不同的浏览器有不同的版本,从其是否支持调试功能可分为:可调试插件和不可调试插件,两者主要区别有:

1) You can connect to it with the remote debugger The (right-click) context menu will include an option to "Show Redraw Regions", which lets you verify how much of your content is being redrawn each frame.

2) The debug player will show a pop-up error message for uncaught exceptions (in the regular player they would fail silently.

3) There are a handful of AS3 commands which only work in the debug player, such as System.gc(). See the System reference.

4) Basically the debug player has a sprinkling of features to make it more suited for development, and anyone developing their own content should probably be using it.

特别注意第2点,debug player在遇见未被不做错误时会弹出错误消息框,而regular player则不会报错。鉴于此,用户在使用flex应用时,往往会碰到不可遇见的怪现象,如用户点了保存按钮没反应,点了查询按钮没反应等。事实上,用户点击保存按钮的时候,程序执行过程中出错了,但是开发人员为捕捉错误,而不可调试player却未报错。

解决:

要解决此怪象,本人认为可以有3种解决方案。

1)所有flex 的代码全部进行try catch处理,估计程序员会变疯;

2)所有用户请使用带调试的插件,估计不是用户会变疯就是支持人员会变疯;

3)进行flex全局错误处理。

很明显,进行flex全局错误处理是比较好的解决方案,但是flex全局错误处理只支持flashplayer10.1及以后的版本,SDK需要4.1版本。因此,对于哪些sdkflashplayer如有严格要求的flex应用就爱莫能助了。下述为flex全局处理的adobe的官方文档的一个例子:

http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/flash/events/UncaughtErrorEvent.html#includeExamplesSummary

遗憾的是flex新提供的错误全局处理机制,只支持applicationsub application,对于module却不支持。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/halo"
applicationComplete="applicationCompleteHandler();">
 <fx:Script>
 <![CDATA[
 import flash.events.ErrorEvent;
 import flash.events.MouseEvent;
 import flash.events.UncaughtErrorEvent;
 
private function applicationCompleteHandler():void
 {
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
 }
 
private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
 {
 if (event.error is Error)
 {
 var error:Error = event.error as Error;
 // do something with the error
 }
 else if (event.error is ErrorEvent)
 {
 var errorEvent:ErrorEvent = event.error as ErrorEvent;
 // do something with the error
 }
 else
 {
 // a non-Error, non-ErrorEvent type was thrown and uncaught
 }
 }
 
private function clickHandler(event:MouseEvent):void
 {
 throw new Error("Gak!");
 }
 ]]>
 </fx:Script>
 
<s:Button label="Cause Error" click="clickHandler(event);"/>
</s:WindowedApplication>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值