· 8 years ago · Jun 15, 2018, 12:47 PM
1package {
2 /*
3 TerryH, terryh.tp at gmail.com
4 license: free to use at no warranty
5 */
6
7 import flash.external.ExternalInterface;
8 public class Debug {
9 public static var enabled:Boolean = true;
10
11 private static const LOG_OP:String = 'console.log';
12 private static const INFO_OP:String = 'console.info';
13 private static const ERROR_OP:String = 'console.error';
14 private static const WARN_OP:String = 'console.warn';
15 private static const DEBUG_OP:String = 'console.debug';
16
17 public static function log(...msg:*):void{
18 send( LOG_OP, msg);
19 }
20 public static function info(...msg:*):void{
21 send( INFO_OP, msg);
22 }
23 public static function warn(...msg:*):void{
24 send( WARN_OP, msg);
25 }
26 public static function error(...msg:*):void{
27 send( ERROR_OP, msg);
28 }
29 public static function debug(...msg:*):void{
30 send( DEBUG_OP, msg);
31 }
32 public static function send(op:String, msg:*):void{
33 if (enabled == true ) {
34 if ( ExternalInterface.available ){
35 for (var i:uint = 0; i< msg.length; i++){
36 ExternalInterface.call(op, msg[i]);
37 }
38 }
39 } else {
40 trace(" Set 'Debug.enable = true;' to enable Debug");
41 }
42 }
43 }
44}