2
我想寫一些代碼來捕獲所有的錯誤和ErrorEvents,但我似乎無法得到它拋出的錯誤,只有ErrorEvents。UncaughtErrorEvent捕獲ErrorEvents但不拋出錯誤
下工作正常
package
{
import flash.display.Sprite;
import flash.events.ErrorEvent;
import flash.events.UncaughtErrorEvent;
public class Main extends Sprite
{
public function Main():void
{
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
}
private function onUncaughtError(e:UncaughtErrorEvent):void
{
trace("Main.onUncaughtError > e : " + e);
e.preventDefault();
}
}
}
但這並不捕獲錯誤,並導致詮釋標準調試播放器錯誤彈出。
package
{
import flash.display.Sprite;
import flash.events.UncaughtErrorEvent;
public class Main extends Sprite
{
public function Main():void
{
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
throw new Error();
}
private function onUncaughtError(e:UncaughtErrorEvent):void
{
trace("Main.onUncaughtError > e : " + e);
e.preventDefault();
}
}
}
這發生在所有支持的玩家10.1和以上。
男人,這一直讓我瘋狂的這一整天,直到我找到你的帖子! )) – pokrishka 2013-11-08 12:11:53