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

  1. package ENGINE.CORE
  2. {
  3.    import flash.utils.getTimer;
  4.    
  5.    public class ORandomInt
  6.    {
  7.        
  8.       
  9.       private var iNextRandom:int;
  10.       
  11.       public function ORandomInt()
  12.       {
  13.          super();
  14.          iNextRandom = getTimer();
  15.       }
  16.       
  17.       public function RandNumber() : Number
  18.       {
  19.          var _loc1_:Number = NaN;
  20.          _loc1_ = Rand();
  21.          return _loc1_ / 32767;
  22.       }
  23.       
  24.       public function Rand() : int
  25.       {
  26.          iNextRandom = iNextRandom * 1103515245 + 12345;
  27.          return iNextRandom >> 16 & 32767;
  28.       }
  29.       
  30.       public function get NextRandom() : int
  31.       {
  32.          return this.iNextRandom;
  33.       }
  34.       
  35.       public function RandOnInterval(param1:Number = 0, param2:Number = 1) : int
  36.       {
  37.          return param1 + Rand() % (1 + param2 - param1);
  38.       }
  39.       
  40.       public function RandVal(param1:int) : int
  41.       {
  42.          var _loc2_:Number = NaN;
  43.          _loc2_ = Rand();
  44.          return _loc2_ % param1;
  45.       }
  46.       
  47.       public function SeedRand(param1:int = 0) : void
  48.       {
  49.          if(param1 == 0)
  50.          {
  51.             iNextRandom = getTimer();
  52.          }
  53.          else
  54.          {
  55.             iNextRandom = param1;
  56.          }
  57.       }
  58.    }
  59. }
  60.