当您在 ActionScript 中使用 Flash Player 的普通版本(非调试版本)时,如何获取错误消息和堆栈跟踪?

发布于 2024-12-05 19:56:09 字数 114 浏览 1 评论 0原文

我想在发布 Flash 应用程序后记录它的错误。
我会将日志保存在网络服务器上的文件中。

您知道当您使用普通版本(非调试版本)的 Flash Player 时如何获取错误消息和堆栈跟踪吗?

I want to log errors of my flash application after I released it.
I will save the logs on files on the web server.

Do you know how to get error message and stack trace when you use normal version(not debug version) of flash player?

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

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

发布评论

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

评论(2

撩动你心 2024-12-12 19:56:09

据我所知,没有办法从 11.5 版之前的 Flash 播放器发行版本中获取堆栈跟踪。然而,2012 年 9 月 26 日的 Flash 播放器 beta 11.5 向发布的播放器添加了基本的堆栈跟踪。使用它时,Error.getStackTrace 会告诉您引发错误的类和函数,但不包括类路径或行。

公告:
http://forums.adobe.com/message/4732775

示例用法:
http://renaun. com/blog/2012/09/getting-the-stack-trace-in-a-release-flash-player/

如果您想从版本 SWF(不是使用 debug=true 构建的)获取堆栈跟踪,请使用调试闪存对于 beta 11.5 之前的玩家,您可以使用标志“-compiler.verbose-stacktraces”构建您的应用程序。

As far as I can find there's no way to get a stack trace from the release version of the Flash player before version 11.5. However, the 9/26/2012 Flash player beta 11.5 added a rudimentary stack trace to the release player. When using it, Error.getStackTrace tells you the class and function where the error was thrown, but does not include the classpath or line.

Announcement:
http://forums.adobe.com/message/4732775

Example usage:
http://renaun.com/blog/2012/09/getting-the-stack-trace-in-a-release-flash-player/

If you want to get stacktraces from a release SWF (one not built with debug=true) using debug Flash players prior to beta 11.5, you can build your app using the flag "-compiler.verbose-stacktraces".

樱娆 2024-12-12 19:56:09

客户端日志记录

如果您想在浏览器中(而不是在 Flash 调试器中)访问调试工具,有多种选择。

最简单的选择是下载浏览器扩展,并继续使用跟踪

我做了很多跨浏览器检查,所以我在 Utils 包中使用了自定义 log 函数来访问 JS 控制台:

init.asloggingEnabled.as

package com.zzzzbov.utils
{
  import flash.external.ExternalInterface;

  public function log(... args):void
  {
    CONFIG::DEBUG
    {
      trace(args);
      if (loggingEnabled && ExternalInterface.available)
      {
        try
        {
          if (init === null)
          {
            init = ExternalInterface.call('eval', 'if(window.flashlog){false;}else{window.flashlog=function(){if(window.console&&console.log){if(console.log.apply){console.log.apply(console,arguments);}else{for(var i=0;i<arguments.length;i++){console.log(arguments[i]);}}}};true;}');
          }

          if (init)
          {
            var values:Array = new Array('flashlog');
            ExternalInterface.call.apply(ExternalInterface, values.concat(args));
          }
        }
        catch (e:Error)
        {
          //nothing really can be done
        }
      }
    }
  }
}

package com.zzzzbov.utils
{
  internal var init:* = null;
}

log.as

package zfl.utils
{
  internal var loggingEnabled:Boolean = true;
}

很多可以改进的地方,以及使用此功能所需的一些东西。您需要定义 CONFIG::DEBUG,此外您还需要向舞台添加一个事件侦听器,以便 Event.ACTIVATEEvent.DEACTIVATE 切换 开启和关闭loggingEnabled以防止闪存崩溃。您还需要提供对 Flash 视频的脚本访问权限。

服务器端日志记录

如果您想使用 Flash 在服务器上记录消息,请使用 URLLoader 发送一个简单的 Url 请求,将消息作为参数传递给服务器端脚本。被调用的日志记录脚本需要使用服务器端语言(例如 PHP 或 ASP.NET)编写。

应注意验证来自 Flash 的请求,以防止恶意访问(您不希望有人将一些可执行代码注入您的文件系统)。

Client Side Logging

If you want to access debugging tools in-browser (rather than in the Flash Debugger), there are a number of options.

The simplest option is to download a browser extension, and continue to use trace.

I do a bunch of cross-browser checking, so I've used a custom log function in my Utils package to access the JS console:

log.as

package com.zzzzbov.utils
{
  import flash.external.ExternalInterface;

  public function log(... args):void
  {
    CONFIG::DEBUG
    {
      trace(args);
      if (loggingEnabled && ExternalInterface.available)
      {
        try
        {
          if (init === null)
          {
            init = ExternalInterface.call('eval', 'if(window.flashlog){false;}else{window.flashlog=function(){if(window.console&&console.log){if(console.log.apply){console.log.apply(console,arguments);}else{for(var i=0;i<arguments.length;i++){console.log(arguments[i]);}}}};true;}');
          }

          if (init)
          {
            var values:Array = new Array('flashlog');
            ExternalInterface.call.apply(ExternalInterface, values.concat(args));
          }
        }
        catch (e:Error)
        {
          //nothing really can be done
        }
      }
    }
  }
}

init.as

package com.zzzzbov.utils
{
  internal var init:* = null;
}

loggingEnabled.as

package zfl.utils
{
  internal var loggingEnabled:Boolean = true;
}

There are a lot of things that can be improved, and a few things that are required to use this function. You'll need CONFIG::DEBUG defined, additionally you'll want to add an event listener to the stage for Event.ACTIVATE and Event.DEACTIVATE to toggle loggingEnabled on and off to prevent flash from crashing. You'll also need to provide script access to the flash video.

Server Side Logging

If you'd like to log messages on a server using Flash, send a simple Url Request using a URLLoader passing the message as a parameter to a server-side script. The logging script being called will need to be written in a server-side language such as PHP or ASP.NET.

Care should be taken to authenticate the request from Flash to prevent malicious access (you wouldn't want someone injecting some executable code into your filesystem).

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