home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / fwg_knight.swf / scripts / __Packages / Mkey.as < prev    next >
Encoding:
Text File  |  2008-08-28  |  1.2 KB  |  69 lines

  1. class Mkey
  2. {
  3.    var nTime;
  4.    var nDelay;
  5.    var bHold;
  6.    var bDouble;
  7.    var nKey;
  8.    var sKey;
  9.    function Mkey(_nKey)
  10.    {
  11.       this.nTime = 0;
  12.       this.nDelay = 400;
  13.       this.bHold = false;
  14.       this.bDouble = false;
  15.       this.nKey = _nKey;
  16.       this.sKey = String.fromCharCode(this.nKey).toUpperCase();
  17.    }
  18.    function up()
  19.    {
  20.    }
  21.    function down()
  22.    {
  23.    }
  24.    function hold()
  25.    {
  26.    }
  27.    function unHold()
  28.    {
  29.    }
  30.    function double()
  31.    {
  32.    }
  33.    function move()
  34.    {
  35.       if(Key.isDown(this.nKey))
  36.       {
  37.          if(this.bHold)
  38.          {
  39.             this.hold();
  40.          }
  41.          else
  42.          {
  43.             this.bHold = true;
  44.             this.down();
  45.             if(getTimer() - this.nTime < this.nDelay)
  46.             {
  47.                this.double();
  48.                this.bDouble = true;
  49.             }
  50.             this.nTime = getTimer();
  51.          }
  52.       }
  53.       else if(this.bHold)
  54.       {
  55.          this.bHold = false;
  56.          if(this.bDouble)
  57.          {
  58.             this.nTime = 0;
  59.             this.bDouble = false;
  60.          }
  61.          this.up();
  62.       }
  63.       else
  64.       {
  65.          this.unHold();
  66.       }
  67.    }
  68. }
  69.