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

  1. package com.google.analytics.debug
  2. {
  3.    import flash.events.KeyboardEvent;
  4.    import flash.ui.Keyboard;
  5.    
  6.    public class Debug extends Label
  7.    {
  8.       public static var count:uint = 0;
  9.       
  10.       private var _lines:Array;
  11.       
  12.       private var _preferredForcedWidth:uint = 540;
  13.       
  14.       private var _linediff:int = 0;
  15.       
  16.       public var maxLines:uint = 16;
  17.       
  18.       public function Debug(param1:uint = 0, param2:Align = null, param3:Boolean = false)
  19.       {
  20.          if(param2 == null)
  21.          {
  22.             param2 = Align.bottom;
  23.          }
  24.          super("","uiLabel",param1,param2,param3);
  25.          this.name = "Debug" + count++;
  26.          _lines = [];
  27.          selectable = true;
  28.          addEventListener(KeyboardEvent.KEY_DOWN,onKey);
  29.       }
  30.       
  31.       public function writeBold(param1:String) : void
  32.       {
  33.          write(param1,true);
  34.       }
  35.       
  36.       private function _getLinesToDisplay(param1:int = 0) : Array
  37.       {
  38.          var _loc2_:Array = null;
  39.          var _loc3_:uint = 0;
  40.          var _loc4_:uint = 0;
  41.          if(_lines.length - 1 > maxLines)
  42.          {
  43.             if(_linediff <= 0)
  44.             {
  45.                _linediff += param1;
  46.             }
  47.             else if(_linediff > 0 && param1 < 0)
  48.             {
  49.                _linediff += param1;
  50.             }
  51.             _loc3_ = uint(_lines.length - maxLines + _linediff);
  52.             _loc4_ = _loc3_ + maxLines;
  53.             _loc2_ = _lines.slice(_loc3_,_loc4_);
  54.          }
  55.          else
  56.          {
  57.             _loc2_ = _lines;
  58.          }
  59.          return _loc2_;
  60.       }
  61.       
  62.       private function onKey(param1:KeyboardEvent = null) : void
  63.       {
  64.          var _loc2_:Array = null;
  65.          switch(param1.keyCode)
  66.          {
  67.             case Keyboard.DOWN:
  68.                _loc2_ = _getLinesToDisplay(1);
  69.                break;
  70.             case Keyboard.UP:
  71.                _loc2_ = _getLinesToDisplay(-1);
  72.                break;
  73.             default:
  74.                _loc2_ = null;
  75.          }
  76.          if(_loc2_ == null)
  77.          {
  78.             return;
  79.          }
  80.          text = _loc2_.join("\n");
  81.       }
  82.       
  83.       override public function get forcedWidth() : uint
  84.       {
  85.          if(this.parent)
  86.          {
  87.             if(UISprite(this.parent).forcedWidth > _preferredForcedWidth)
  88.             {
  89.                return _preferredForcedWidth;
  90.             }
  91.             return UISprite(this.parent).forcedWidth;
  92.          }
  93.          return super.forcedWidth;
  94.       }
  95.       
  96.       public function write(param1:String, param2:Boolean = false) : void
  97.       {
  98.          var _loc3_:Array = null;
  99.          if(param1.indexOf("") > -1)
  100.          {
  101.             _loc3_ = param1.split("\n");
  102.          }
  103.          else
  104.          {
  105.             _loc3_ = [param1];
  106.          }
  107.          var _loc4_:String = "";
  108.          var _loc5_:String = "";
  109.          if(param2)
  110.          {
  111.             _loc4_ = "<b>";
  112.             _loc5_ = "</b>";
  113.          }
  114.          var _loc6_:int = 0;
  115.          while(_loc6_ < _loc3_.length)
  116.          {
  117.             _lines.push(_loc4_ + _loc3_[_loc6_] + _loc5_);
  118.             _loc6_++;
  119.          }
  120.          var _loc7_:Array = _getLinesToDisplay();
  121.          text = _loc7_.join("\n");
  122.       }
  123.       
  124.       public function close() : void
  125.       {
  126.          dispose();
  127.       }
  128.       
  129.       override protected function dispose() : void
  130.       {
  131.          removeEventListener(KeyboardEvent.KEY_DOWN,onKey);
  132.          super.dispose();
  133.       }
  134.    }
  135. }
  136.  
  137.