home *** CD-ROM | disk | FTP | other *** search
/ Ice Age Fan CD 1 / CD1_Scrat.iso / flash / data / game.swf / scripts / Debug.as < prev    next >
Encoding:
Text File  |  2012-07-04  |  5.2 KB  |  183 lines

  1. package
  2. {
  3.    import flash.display.BitmapData;
  4.    import flash.display.Stage;
  5.    import flash.events.StatusEvent;
  6.    import flash.geom.Matrix;
  7.    import flash.geom.Rectangle;
  8.    import flash.net.LocalConnection;
  9.    import flash.system.System;
  10.    
  11.    public class Debug
  12.    {
  13.       public static const NAME:String = "Debug";
  14.       
  15.       public static const VERSION:String = "0.74";
  16.       
  17.       public static var password:String = "CDC309AF";
  18.       
  19.       public static var RED:uint = 13369344;
  20.       
  21.       public static var GREEN:uint = 52224;
  22.       
  23.       public static var BLUE:uint = 6710988;
  24.       
  25.       public static var PINK:uint = 13369548;
  26.       
  27.       public static var YELLOW:uint = 13421568;
  28.       
  29.       public static var LIGHT_BLUE:uint = 52428;
  30.       
  31.       public static var ignoreStatus:Boolean = true;
  32.       
  33.       public static var secure:Boolean = false;
  34.       
  35.       public static var secureDomain:String = "*";
  36.       
  37.       public static var allowLog:Boolean = true;
  38.       
  39.       private static const DOMAIN:String = "com.carlcalderon.Arthropod";
  40.       
  41.       private static const CHECK:String = ".161E714B6C1A76DE7B9865F88B32FCCE8FABA7B5.1";
  42.       
  43.       private static const TYPE:String = "app";
  44.       
  45.       private static const CONNECTION:String = "arthropod";
  46.       
  47.       private static const LOG_OPERATION:String = "debug";
  48.       
  49.       private static const ERROR_OPERATION:String = "debugError";
  50.       
  51.       private static const WARNING_OPERATION:String = "debugWarning";
  52.       
  53.       private static const ARRAY_OPERATION:String = "debugArray";
  54.       
  55.       private static const BITMAP_OPERATION:String = "debugBitmapData";
  56.       
  57.       private static const OBJECT_OPERATION:String = "debugObject";
  58.       
  59.       private static const MEMORY_OPERATION:String = "debugMemory";
  60.       
  61.       private static const CLEAR_OPERATION:String = "debugClear";
  62.       
  63.       private static var lc:LocalConnection = new LocalConnection();
  64.       
  65.       private static var hasEventListeners:Boolean = false;
  66.       
  67.       public function Debug()
  68.       {
  69.          super();
  70.       }
  71.       
  72.       public static function log(param1:*, param2:uint = 16711422) : Boolean
  73.       {
  74.          return send(LOG_OPERATION,String(param1),param2);
  75.       }
  76.       
  77.       public static function error(param1:*) : Boolean
  78.       {
  79.          return send(ERROR_OPERATION,String(param1),13369344);
  80.       }
  81.       
  82.       public static function warning(param1:*) : Boolean
  83.       {
  84.          return send(WARNING_OPERATION,String(param1),13421568);
  85.       }
  86.       
  87.       public static function clear() : Boolean
  88.       {
  89.          return send(CLEAR_OPERATION,0,0);
  90.       }
  91.       
  92.       public static function array(param1:Array) : Boolean
  93.       {
  94.          return send(ARRAY_OPERATION,param1,null);
  95.       }
  96.       
  97.       public static function bitmap(param1:*, param2:String = null) : Boolean
  98.       {
  99.          var _loc3_:BitmapData = new BitmapData(100,100,true,16777215);
  100.          var _loc4_:Matrix = new Matrix();
  101.          var _loc5_:Number = 100 / (param1.width >= param1.height ? param1.width : param1.height);
  102.          _loc4_.scale(_loc5_,_loc5_);
  103.          _loc3_.draw(param1,_loc4_,null,null,null,true);
  104.          var _loc6_:Rectangle = new Rectangle(0,0,Math.floor(param1.width * _loc5_),Math.floor(param1.height * _loc5_));
  105.          return send(BITMAP_OPERATION,_loc3_.getPixels(_loc6_),{
  106.             "bounds":_loc6_,
  107.             "lbl":param2
  108.          });
  109.       }
  110.       
  111.       public static function snapshot(param1:Stage, param2:String = null) : Boolean
  112.       {
  113.          if(param1)
  114.          {
  115.             return bitmap(param1,param2);
  116.          }
  117.          return false;
  118.       }
  119.       
  120.       public static function object(param1:*) : Boolean
  121.       {
  122.          return send(OBJECT_OPERATION,param1,null);
  123.       }
  124.       
  125.       public static function memory() : Boolean
  126.       {
  127.          return send(MEMORY_OPERATION,System.totalMemory,null);
  128.       }
  129.       
  130.       private static function send(param1:String, param2:*, param3:*) : Boolean
  131.       {
  132.          var operation:String = param1;
  133.          var value:* = param2;
  134.          var prop:* = param3;
  135.          if(!secure)
  136.          {
  137.             lc.allowInsecureDomain("*");
  138.          }
  139.          else
  140.          {
  141.             lc.allowDomain(secureDomain);
  142.          }
  143.          if(!hasEventListeners)
  144.          {
  145.             if(ignoreStatus)
  146.             {
  147.                lc.addEventListener(StatusEvent.STATUS,ignore);
  148.             }
  149.             else
  150.             {
  151.                lc.addEventListener(StatusEvent.STATUS,status);
  152.             }
  153.             hasEventListeners = true;
  154.          }
  155.          if(allowLog)
  156.          {
  157.             try
  158.             {
  159.                lc.send(TYPE + "#" + DOMAIN + CHECK + ":" + CONNECTION,operation,password,value,prop);
  160.                return true;
  161.             }
  162.             catch(e:*)
  163.             {
  164.                return false;
  165.             }
  166.          }
  167.          else
  168.          {
  169.             return false;
  170.          }
  171.       }
  172.       
  173.       private static function status(param1:StatusEvent) : void
  174.       {
  175.       }
  176.       
  177.       private static function ignore(param1:StatusEvent) : void
  178.       {
  179.       }
  180.    }
  181. }
  182.  
  183.