home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / aliendash.swf / scripts / DefineSprite_20 / frame_1 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  2.7 KB  |  138 lines

  1. if(_root.milliseconds == 0)
  2. {
  3.    if(0 < _root.time)
  4.    {
  5.       _root.milliseconds = 60;
  6.       _root.time--;
  7.    }
  8.    else
  9.    {
  10.       _root.message.gotoAndPlay("time");
  11.       _parent.gotoAndStop("done");
  12.    }
  13. }
  14. else
  15. {
  16.    _root.milliseconds -= 2;
  17. }
  18. if(_parent._x != _parent.dest_x || _parent._y != _parent.dest_y)
  19. {
  20.    _parent.walking = true;
  21.    if(_parent._currentFrame == 1)
  22.    {
  23.       _parent.gotoAndStop("walk");
  24.    }
  25. }
  26. else
  27. {
  28.    _parent.walking = false;
  29.    if(_parent._currentFrame == 2)
  30.    {
  31.       _parent.gotoAndStop("stand");
  32.    }
  33. }
  34. if(_parent._x + _root.speed < _parent.dest_x)
  35. {
  36.    _parent._x += _root.speed;
  37.    _parent._rotation = 90;
  38. }
  39. else if(_parent.dest_x < _parent._x - _root.speed)
  40. {
  41.    _parent._x -= _root.speed;
  42.    _parent._rotation = -90;
  43. }
  44. else
  45. {
  46.    _parent.dest_x = _parent._x;
  47. }
  48. if(_parent._y + _root.speed < _parent.dest_y)
  49. {
  50.    _parent._y += _root.speed;
  51.    _parent._rotation = 180;
  52. }
  53. else if(_parent.dest_y < _parent._y - _root.speed)
  54. {
  55.    _parent._y -= _root.speed;
  56.    _parent._rotation = 0;
  57. }
  58. else
  59. {
  60.    _parent.dest_y = _parent._y;
  61. }
  62. if(Key.isDown(Key.RIGHT))
  63. {
  64.    _parent.key_right = _parent.key_right + 1;
  65. }
  66. else
  67. {
  68.    _parent.key_right = 0;
  69. }
  70. if(Key.isDown(Key.LEFT))
  71. {
  72.    _parent.key_left = _parent.key_left + 1;
  73. }
  74. else
  75. {
  76.    _parent.key_left = 0;
  77. }
  78. if(Key.isDown(Key.DOWN))
  79. {
  80.    _parent.key_down = _parent.key_down + 1;
  81. }
  82. else
  83. {
  84.    _parent.key_down = 0;
  85. }
  86. if(Key.isDown(Key.UP))
  87. {
  88.    _parent.key_up = _parent.key_up + 1;
  89. }
  90. else
  91. {
  92.    _parent.key_up = 0;
  93. }
  94. if(_parent.walking != true)
  95. {
  96.    if(Key.isDown(Key.RIGHT) && (_parent.key_left == 0 || _parent.key_right < _parent.key_left) && _parent._x < _root.limit_right)
  97.    {
  98.       _parent.dest_x = _parent._x + 80;
  99.    }
  100.    if(Key.isDown(Key.LEFT) && (_parent.key_right == 0 || _parent.key_left < _parent.key_right) && _root.limit_left < _parent._x)
  101.    {
  102.       _parent.dest_x = _parent._x - 80;
  103.    }
  104.    if(_parent.dest_x == _parent._x)
  105.    {
  106.       if(Key.isDown(Key.DOWN) && _parent._y < _root.limit_down)
  107.       {
  108.          _parent.dest_y = _parent._y + 80;
  109.       }
  110.       if(Key.isDown(Key.UP) && _root.limit_up < _parent._y)
  111.       {
  112.          _parent.dest_y = _parent._y - 80;
  113.       }
  114.    }
  115. }
  116. if(_root.limit_right < _parent._x)
  117. {
  118.    _parent._x = _root.limit_right;
  119.    _parent.dest_x = _parent._x;
  120. }
  121. else if(_parent._x < _root.limit_left)
  122. {
  123.    _parent._x = _root.limit_left;
  124.    _parent.dest_x = _parent._x;
  125. }
  126. if(_root.limit_down < _parent._y)
  127. {
  128.    _parent._y = _root.limit_down;
  129.    _parent.dest_y = _parent._y;
  130. }
  131. else if(_parent._y < _root.limit_up)
  132. {
  133.    _parent._y = _root.limit_up;
  134.    _parent.dest_y = _parent._y;
  135.    _root.gotoAndStop("clear");
  136.    _parent.gotoAndStop("done");
  137. }
  138.