2012-02-24 53 views
2

我有Firefox,Firebug,Flashbug和* .fla + * .as文件的flash widged。是否可以使用跟踪槽作为可变手表等代码进行调试?如何?如何在网页中跟踪ActionScript?

编辑

我有flasbug,可以看到trace命令的输出。但是我需要像其他调试器一样一步一步地进行调试,而且Flash Professional可以处理独立的Flash电影。

+0

尝试使用flashbug https://addons.mozilla.org/fr/firefox/addon/flashbug/ – mgraph 2012-02-24 16:29:27

+0

后来我写了一些代码,挂钩到'ExternalInterface'中以使用'console.log'和类似的,所以我不必为闪存安装一个单独的插件。嵌入闪光灯时,您还需要设置'allowcriptaccess'参数。作为一个警告,它涉及调用'eval'来初始化一个函数,以便我挂钩到'console.log'。 – zzzzBov 2012-02-24 16:31:58

回答

3

您可以简单地使用Flash调试器。 :)见this article from Adobe。可以使用MonsterDebugger

+0

谢谢!我看到这篇文章,但并不理解它。像“远程调试仅限于位于同一本地主机上的文件”这样的短语让我不安。如果它是同一个本地主机,什么“远程”字可以表示?同样在这里:“如果你将文件上传到远程服务器,你将无法遍历代码”。我需要这个:来自远程服务器的跟踪文件。 – 2012-02-27 17:28:58

+0

1)这意味着你不能在调试器中调试东西,除非你在自己的机器上运行服务器。 2)你可以在任何地方使用跟踪,而且你不需要调试器。您只需使用内容调试器Flash Player并启用日志记录即可。看到这篇文章:http://jpauclair.net/2010/02/10/mmcfg-treasure – weltraumpirat 2012-02-28 11:31:19

+0

或:使用MonsterDebugger;) – weltraumpirat 2012-02-28 11:32:00

0

我正在搞ExternalInterface因为我认为可能有比我以前的方法更好的方式来访问控制台,我发现ExternalInterface.call的第一个参数可以指定不仅仅是一个函数来调用。

我写了这个功能使用JavaScript consoletrace简化到:

Console.log(...); 

或者在条件编译块:

CONFIG::DEBUG { 
    Console.log(...); 
} 

/** 
* @author zzzzBov <[email protected]> 
* @version 0.1 
* @since  2012-02-24 
*/ 
package com.zzzzbov.debug { 
    import flash.external.ExternalInterface; 

    /** 
    * `com.zzzzbov.debug.Console` is a debugging tool to interface with web browsers' developer consoles. 
    */ 
    public class Console { 

     /** 
     * The hidden utility method to make `ExternalInterface` calls to JavaScript. 
     * 
     * @param type the type of console function that will be called 
     * @param args the array of arguments to pass to the console[type] function 
     */ 
     private static function console(type:String, args:Array = null):void { 
      //prevents an additional `null` from being passed as an argument when the second parameter is skipped 
      if (args === null) { 
       args = []; 
      } 
      //Checks that the ExternalInterface is available and that console[type] exists 
      if (ExternalInterface.available && ExternalInterface.call('function() {return !!(console && ("' + type + '" in console));}')) { 
       //calls the console[type] function with the provided arguments. 
       ExternalInterface.call.apply(ExternalInterface, ['console.'+type].concat(args)); 
      } else { 
       //calls `trace` if console[type] isn't available 
       trace.apply(null, [type].concat(args)); 
      } 
     } 

     /** 
     * Checks the truthiness of {@param expr}; if the assertion fails, it also prints out {@param args}. 
     * 
     * @param expr an expression to test 
     * @param args the message to print to the console 
     */ 
     public static function assert(expr:*, ... args):void { 
      console('assert', [expr].concat(args)); 
     } 

     /** 
     * Clears the console of messages 
     */ 
     public static function clear():void { 
      console('clear'); 
     } 

     /** 
     * Writes the number of times that count was executed. The {@param title} will be printed in addition to the count. 
     * 
     * Warning: No IE support 
     * 
     * @param title A title for a particular counter 
     */ 
     public static function count(title:String = null):void { 
      console('count', title != null ? [title] : []); 
     } 

     /** 
     * Writes the arguments to the console. 
     * 
     * Warning: No IE support. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function debug(... args):void { 
      console('debug', args); 
     } 

     /** 
     * Prints an interactive listing of all properties on {@param obj}. 
     * 
     * @param obj the object to expand 
     */ 
     public static function dir(obj:*):void { 
      console('dir', [obj]); 
     } 

     /** 
     * Prints an XML source tree of an HTML or XML element. 
     * 
     * Warning: No IE support; source tree may not be fully supported. 
     */ 
     public static function dirxml(node:*):void { 
      console('dirxml', [node]); 
     } 

     /** 
     * Writes the arguments to the console as an error message. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function error(... args):void { 
      console('error', args); 
     } 
     /** 
     * Writes a message to the console and opens a nested block for future console messages. 
     * 
     * Warning: No IE support. Call {@link #groupEnd()} to close the block. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function group(... args):void { 
      console('group', args); 
     } 

     /** 
     * Writes a message to the console and opens a collapsed, nested block for future console messages. 
     * 
     * Warning: No IE support. Call {@link #groupEnd()} to close the block. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function groupCollapsed(... args):void { 
      console('groupCollapsed', args); 
     } 

     /** 
     * Closes the block most recently opened by {@link #group(...)} or {@link #groupCollapsed(...)}. 
     * 
     * Warning: No IE support. 
     */ 
     public static function groupEnd():void { 
      console('groupEnd'); 
     } 

     /** 
     * Writes the arguments to the console as an informational message. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function info(... args):void { 
      console('info', args); 
     } 

     /** 
     * Writes the arguments to the console. 
     * 
     * The first argument may use a printf-like syntax for substituting subsequent arguments into a formatted message. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function log(... args):void { 
      console('log', args); 
     } 

     /** 
     * Turns on the JavaScript profiler. 
     * 
     * Call {@link #profileEnd()} to stop profiling and print the profiler report. 
     * 
     * @param title the title to print in the header of the profile report 
     */ 
     public static function profile(title:String = null):void { 
      console('profile', title != null ? [title] : []); 
     } 

     /** 
     * Turns off the JavaScript profiler and prints the profiler report. 
     */ 
     public static function profileEnd():void { 
      console('profileEnd'); 
     } 
     /** 
     * Creates a new timer with the given name. 
     * 
     * Warning: No IE support. Call {@link #timeEnd(name)} to stop the timer and print the elapsed time. 
     * 
     * @param name the name of the timer to start 
     */ 
     public static function time(name:String):void { 
      console('time', [name]); 
     } 

     /** 
     * Stops the timer with the provided name and prints the elapsed time to the console. 
     * 
     * Warning: No IE support. Call {@link #time(name)} to start a timer of a given name. 
     * 
     * @param name the name of the timer to stop 
     */ 
     public static function timeEnd(name:String):void { 
      console('timeEnd', [name]); 
     } 

     /** 
     * Writes the arguments to the console as a warning. 
     * 
     * @param args the arguments to print in the console 
     */ 
     public static function warn(... args):void { 
      console('warn', args); 
     } 
    } 
} 

让我知道如果你发现任何问题,或有任何建议秒。