确定是否SWF处于"调试"播放器或模式 [英] Determine if swf is in a "debug" player or mode

查看:202
本文介绍了确定是否SWF处于"调试"播放器或模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用Flash(CS3 + AS3),以确定是否已发布的SWF在调试播放器或闪存的调试模式下运行的方式?

Is there a way using Flash (CS3+AS3) to determine if the published swf is running in a debug player or in Flash's debug mode?

我知道,Flex提供的能力,设置不同的构建目标(发布/调试),并可以使用类似 CONFIG ::调试的#ifdef 风格入选的code在编译的时候。

I'm aware that Flex provides the ability to setup different build targets (release/debug) and that you can use something like CONFIG::debug for #ifdef style inclusion of code at compile time.

我想象像 System.isDebug(),但无法找到任何东西。我想用这个,因为有一个在我的应用程序的调试功能,我的绝对的不想可用在生产环境中。

I'm imagining something like System.isDebug() but can't find anything. I want to use this because there's debug functionality in my app that I definitely don't want to be available in a production environment.

推荐答案

看看这个类的<一个href="http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/">http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/

这个类提供了两个相关的(不同)部分信息:

This class provides two pertinent (and different) pieces of information:

  • 在建与-debug开关(已调试符号编译)?在SWF
  • Flash Player的调试播放器(有显示错误的能力等)?

该Capabilities.isDebugger只回答了第二个问题 - 是运行Flash调试播放器的用户。你的情况,你在调试版本的应用程序的栅极部分,你想要的-debug建立检查(然后不交-debug建立投入生产)。

The Capabilities.isDebugger only answers the second question - is the user running the Flash Debug player. In your case, to gate portions of your application on a debug build, you want the -debug build check (and then don't deliver -debug builds into production).

请注意但是,这两种检查都运行时检查。使用条件编译(又名CONFIG ::调试)在你的调试code仍然是一个好主意,因为这将确保可能敏感调试code是最终的SWF未交付,使得它作为小和安全的,因为可能的。

Note however, that both these checks are runtime checks. Using conditional compilation (aka CONFIG::debug) around your debug code is still a good idea, as it will ensure that possibly sensitive debug code is NOT delivered in the final SWF, making it as small and secure as possible.

我复制引用code在这里,万一博客链接不断下降:

I'm reproducing the referenced code here, in case the blog link ever goes down:

package org.adm.runtime
{
  import flash.system.Capabilities;

  public class ModeCheck
  {
    /**
     * Returns true if the user is running the app on a Debug Flash Player.
     * Uses the Capabilities class
     **/
    public static function isDebugPlayer() : Boolean
    {
        return Capabilities.isDebugger;
    }

    /**
     * Returns true if the swf is built in debug mode
     **/
    public static function isDebugBuild() : Boolean
    {
        var stackTrace:String = new Error().getStackTrace();
        return (stackTrace && stackTrace.search(/:[0-9]+]$/m) > -1);
    }

    /**
     * Returns true if the swf is built in release mode
     **/
    public static function isReleaseBuild() : Boolean
    {
        return !isDebugBuild();
    }
  }
}

这篇关于确定是否SWF处于&QUOT;调试&QUOT;播放器或模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆