home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / Clusterz / Clusterz.swf / scripts / ENGINE / INTERFACE / OCounter.as < prev    next >
Encoding:
Text File  |  2008-09-12  |  5.9 KB  |  219 lines

  1. package ENGINE.INTERFACE
  2. {
  3.    import ENGINE.INTERFACE.ANIMATORS.*;
  4.    
  5.    public class OCounter extends OIObject
  6.    {
  7.       
  8.       public static const iDefAnimators:Array = [{
  9.          "F":OA_Alpha.Make,
  10.          "iSAlpha":0,
  11.          "iEAlpha":1,
  12.          "iPIter":6
  13.       },{
  14.          "F":OA_Alpha.Make,
  15.          "iSAlpha":-1,
  16.          "iEAlpha":0,
  17.          "iPIter":6
  18.       },{
  19.          "F":OA_Alpha.Make,
  20.          "iSAlpha":-1,
  21.          "iEAlpha":1,
  22.          "iPIter":6
  23.       },{
  24.          "F":OA_Alpha.Make,
  25.          "iSAlpha":-1,
  26.          "iEAlpha":0.2,
  27.          "iPIter":6
  28.       },null,null,null,null,null,null];
  29.        
  30.       
  31.       public var iSeparator:OIObject;
  32.       
  33.       public var iDigits0:Array;
  34.       
  35.       public var iDigits:Array;
  36.       
  37.       protected var iValue:int;
  38.       
  39.       protected var iValue0:int;
  40.       
  41.       protected var iWidth:Number;
  42.       
  43.       protected var iHeight:Number;
  44.       
  45.       public function OCounter(param1:Array, param2:Number, param3:Number, param4:Array = null)
  46.       {
  47.          var _loc5_:Array = null;
  48.          this.iWidth = param2;
  49.          this.iHeight = param3;
  50.          _loc5_ = !!param4 ? param4 : iDefAnimators;
  51.          super(param1,_loc5_);
  52.       }
  53.       
  54.       public function set prValue0(param1:int) : void
  55.       {
  56.          this.iValue0 = Math.max(param1,0);
  57.          if(!this.iDigits0)
  58.          {
  59.             return;
  60.          }
  61.          this.iValue0 = Math.min(this.iValue0,Math.pow(10,this.iDigits0.length) - 1);
  62.          Draw();
  63.       }
  64.       
  65.       public function set prValue(param1:int) : void
  66.       {
  67.          this.iValue = Math.max(param1,0);
  68.          if(!this.iDigits)
  69.          {
  70.             return;
  71.          }
  72.          this.iValue = Math.min(this.iValue,Math.pow(10,this.iDigits.length) - 1);
  73.          Draw();
  74.       }
  75.       
  76.       override public function Init() : void
  77.       {
  78.          this.iDigits = new Array();
  79.          this.iDigits0 = new Array();
  80.          super.Init();
  81.       }
  82.       
  83.       private function Draw() : void
  84.       {
  85.          var _loc1_:Number = NaN;
  86.          var _loc2_:String = null;
  87.          var _loc3_:String = null;
  88.          var _loc4_:int = 0;
  89.          var _loc5_:Number = NaN;
  90.          var _loc6_:int = 0;
  91.          _loc1_ = 0;
  92.          _loc2_ = this.iValue0.toString();
  93.          _loc3_ = this.iValue.toString();
  94.          _loc4_ = 0;
  95.          while(_loc4_ < this.iDigits0.length)
  96.          {
  97.             this.iDigits0[_loc4_].prAnimationEnabled = this.iAEnabled;
  98.             _loc4_++;
  99.          }
  100.          _loc4_ = 0;
  101.          while(_loc4_ < this.iDigits.length)
  102.          {
  103.             this.iDigits[_loc4_].prAnimationEnabled = this.iAEnabled;
  104.             _loc4_++;
  105.          }
  106.          if(this.iDigits0.length)
  107.          {
  108.             _loc4_ = _loc2_.length - 1;
  109.             while(_loc4_ >= 0)
  110.             {
  111.                this.iDigits0[_loc4_].prValue = _loc2_.charCodeAt(_loc4_) - 47;
  112.                _loc4_--;
  113.             }
  114.             _loc6_ = this.iDigits0.length - _loc2_.length;
  115.             _loc4_ = 0;
  116.             while(_loc4_ < _loc6_)
  117.             {
  118.                if(this.iDigits0[_loc4_].prValue)
  119.                {
  120.                   this.iDigits0[_loc4_].prValue = 0;
  121.                }
  122.                _loc4_++;
  123.             }
  124.          }
  125.          if(this.iDigits.length)
  126.          {
  127.             _loc4_ = 0;
  128.             while(_loc4_ < _loc3_.length)
  129.             {
  130.                this.iDigits[_loc4_].prValue = _loc3_.charCodeAt(_loc4_) - 47;
  131.                _loc4_++;
  132.             }
  133.             _loc6_ = int(this.iDigits.length);
  134.             _loc4_ = _loc3_.length;
  135.             while(_loc4_ < _loc6_)
  136.             {
  137.                if(this.iDigits[_loc4_].prValue)
  138.                {
  139.                   this.iDigits[_loc4_].prValue = 0;
  140.                }
  141.                _loc4_++;
  142.             }
  143.          }
  144.          if(this.iDigits0.length)
  145.          {
  146.             _loc4_ = _loc2_.length - 1;
  147.             while(_loc4_ >= 0)
  148.             {
  149.                _loc1_ += this.iDigits0[_loc4_].prWidth;
  150.                _loc4_--;
  151.             }
  152.          }
  153.          if(this.iSeparator)
  154.          {
  155.             _loc1_ += this.iSeparator.prWidth;
  156.          }
  157.          if(this.iDigits.length)
  158.          {
  159.             _loc4_ = 0;
  160.             while(_loc4_ < _loc3_.length)
  161.             {
  162.                _loc1_ += this.iDigits[_loc4_].prWidth;
  163.                _loc4_++;
  164.             }
  165.          }
  166.          _loc5_ = (this.iWidth - _loc1_) / 2;
  167.          if(this.iDigits0.length)
  168.          {
  169.             _loc4_ = 0;
  170.             while(_loc4_ < this.iDigits0.length)
  171.             {
  172.                if(this.iDigits0[_loc4_].prValue)
  173.                {
  174.                   this.iDigits0[_loc4_].PosValue(_loc5_,(this.iWidth - this.iDigits0[_loc4_].prHeight) / 2);
  175.                   _loc5_ += this.iDigits0[_loc4_].prWidth;
  176.                }
  177.                _loc4_++;
  178.             }
  179.          }
  180.          if(this.iSeparator)
  181.          {
  182.             this.iSeparator.Pos(_loc5_,(this.iHeight - this.iSeparator.prHeight) / 2);
  183.             _loc5_ += this.iSeparator.prWidth;
  184.          }
  185.          if(this.iDigits.length)
  186.          {
  187.             _loc4_ = 0;
  188.             while(_loc4_ < this.iDigits.length)
  189.             {
  190.                if(this.iDigits[_loc4_].prValue)
  191.                {
  192.                   this.iDigits[_loc4_].PosValue(_loc5_,(this.iHeight - this.iDigits[_loc4_].prHeight) / 2);
  193.                   _loc5_ += this.iDigits[_loc4_].prWidth;
  194.                }
  195.                _loc4_++;
  196.             }
  197.          }
  198.       }
  199.       
  200.       public function get prValue0() : int
  201.       {
  202.          return this.iValue0;
  203.       }
  204.       
  205.       override public function Free() : void
  206.       {
  207.          this.iDigits = null;
  208.          this.iDigits0 = null;
  209.          this.iSeparator = null;
  210.          super.Free();
  211.       }
  212.       
  213.       public function get prValue() : int
  214.       {
  215.          return this.iValue;
  216.       }
  217.    }
  218. }
  219.