home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / fwg_knight.swf / scripts / DefineSprite_341 / frame_1 / DoAction.as
Encoding:
Text File  |  2008-08-28  |  2.6 KB  |  151 lines

  1. function reset()
  2. {
  3.    _rotation = 90 * !horizontal;
  4.    btMid._x = nNow;
  5.    btLeft._x = (- btMid._width) / 2;
  6.    btRight._x = btMid._width / 2 + nMax;
  7.    btBack._x = (- btMid._width) / 2;
  8.    btBack._width = nMax + btMid._width;
  9.    btMid._y = btBack._y = btRight._y = btLeft._y = 0;
  10. }
  11. function dir_hold(vx)
  12. {
  13.    if(nTimeNow == 0 || nTimeNow == nTimeMax)
  14.    {
  15.       if(vx != 0)
  16.       {
  17.          btMid._x += nPer * vx;
  18.       }
  19.       else
  20.       {
  21.          btMid._x -= Common.vpNum(btMid._x - _xmouse) * btMid._width;
  22.       }
  23.       if(btMid._x < 0)
  24.       {
  25.          btMid._x = 0;
  26.       }
  27.       else if(btMid._x > nMax)
  28.       {
  29.          btMid._x = nMax;
  30.       }
  31.       nNow = btMid._x;
  32.    }
  33.    nTimeNow < nTimeMax && nTimeNow++;
  34. }
  35. function getTop()
  36. {
  37.    return btLeft._width + btMid._width / 2;
  38. }
  39. function getSide()
  40. {
  41.    return btMid._height / 2;
  42. }
  43. function getValue()
  44. {
  45.    return int(nNow);
  46. }
  47. function setValue(n)
  48. {
  49.    nNow = n;
  50.    reset();
  51. }
  52. if(typeof eval(nNow) == "function")
  53. {
  54.    nNow = nNow();
  55. }
  56. else if(typeof eval(nNow) == "number")
  57. {
  58.    nNow = eval(nNow);
  59. }
  60. else
  61. {
  62.    nNow = Number(nNow);
  63. }
  64. var nMax;
  65. var horizontal;
  66. var nPer;
  67. var bAutoSiza;
  68. var nTimeMax = 15;
  69. var nTimeNow = 0;
  70. var bRoll = false;
  71. btMid.onPress = function()
  72. {
  73.    startDrag(this,0,0,0,this._parent.nMax,0);
  74.    with(this._parent)
  75.    {
  76.       bRoll = true;
  77.       onEnterFrame = function()
  78.       {
  79.          nNow = btMid._x;
  80.          onhold(0);
  81.       };
  82.    }
  83. };
  84. btBack.onPress = function()
  85. {
  86.    with(this._parent)
  87.    {
  88.       bRoll = true;
  89.       onEnterFrame = function()
  90.       {
  91.          dir_hold(0);
  92.          onhold(2);
  93.       };
  94.    }
  95. };
  96. btRight.onPress = function()
  97. {
  98.    with(this._parent)
  99.    {
  100.       bRoll = true;
  101.       onEnterFrame = function()
  102.       {
  103.          dir_hold(1);
  104.          onhold(1);
  105.       };
  106.    }
  107. };
  108. btLeft.onPress = function()
  109. {
  110.    with(this._parent)
  111.    {
  112.       bRoll = true;
  113.       onEnterFrame = function()
  114.       {
  115.          dir_hold(-1);
  116.          onhold(-1);
  117.       };
  118.    }
  119. };
  120. btMid.onReleaseOutside = btMid.onRelease = function()
  121. {
  122.    stopDrag();
  123.    with(this._parent)
  124.    {
  125.       bRoll = false;
  126.       delete onEnterFrame;
  127.       onreleas(0);
  128.    }
  129. };
  130. btBack.onDragOut = btBack.onRelease = function()
  131. {
  132.    with(this._parent)
  133.    {
  134.       bRoll = false;
  135.       delete onEnterFrame;
  136.       onreleas(2);
  137.       nTimeNow = 0;
  138.    }
  139. };
  140. btLeft.onReleaseOutside = btLeft.onRelease = btRight.onReleaseOutside = btRight.onRelease = function()
  141. {
  142.    with(this._parent)
  143.    {
  144.       bRoll = false;
  145.       delete onEnterFrame;
  146.       onreleas(1);
  147.       nTimeNow = 0;
  148.    }
  149. };
  150. reset();
  151.