home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Corrida / dragracer.swf / scripts / frame_465 / DoAction.as < prev   
Encoding:
Text File  |  2005-10-06  |  3.3 KB  |  88 lines

  1. with(joystick)
  2. {
  3.    if(!Key.isDown(32))
  4.    {
  5.       if(dragging)
  6.       {
  7.          var p = 0;
  8.          while(p <= 10)
  9.          {
  10.             angle = Math.atan2(knob._ymouse - knob._y,knob._xmouse - knob._x);
  11.             var bool = false;
  12.             var newx = 0;
  13.             var newy = 0;
  14.             if(Math.abs(knob._x - _root._xmouse) > 10)
  15.             {
  16.                newx = knob._x + Math.cos(angle) * 5;
  17.                var i = 1;
  18.                while(i <= 4)
  19.                {
  20.                   if(_root["GEARCHECK" add i].hittest(newx + _x,knob._y + _y))
  21.                   {
  22.                      knob._x = newx;
  23.                   }
  24.                   i++;
  25.                }
  26.             }
  27.             if(Math.abs(knob._y - _root._ymouse) > 10)
  28.             {
  29.                newy = knob._y + Math.sin(angle) * 5;
  30.                var i = 1;
  31.                while(i <= 4)
  32.                {
  33.                   if(_root["GEARCHECK" add i].hittest(knob._x + _x,newy + _y))
  34.                   {
  35.                      knob._y = newy;
  36.                   }
  37.                   i++;
  38.                }
  39.             }
  40.             with(knob)
  41.             {
  42.                if(_root.GEARCHECK1.G3.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  43.                {
  44.                   gear = 1;
  45.                   data1.g = 1;
  46.                }
  47.                else if(_root.GEARCHECK1.G4.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  48.                {
  49.                   gear = 2;
  50.                   data1.g = 2;
  51.                }
  52.                else if(_root.GEARCHECK2.G3.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  53.                {
  54.                   gear = 3;
  55.                   data1.g = 3;
  56.                }
  57.                else if(_root.GEARCHECK2.G4.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  58.                {
  59.                   gear = 4;
  60.                   data1.g = 4;
  61.                }
  62.                else if(_root.GEARCHECK3.G3.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  63.                {
  64.                   gear = 5;
  65.                   data1.g = 5;
  66.                }
  67.                else if(_root.GEARCHECK3.G4.hittest(_x + _parent._x + _parent._parent._x,_y + _parent._y + _parent._parent._y))
  68.                {
  69.                   gear = 6;
  70.                   data1.g = 6;
  71.                }
  72.             }
  73.             p++;
  74.          }
  75.          shaft._xscale = Math.sqrt((knob._x - shaft._x) * (knob._x - shaft._x) + (knob._y - shaft._y) * (knob._y - shaft._y));
  76.          shaft._rotation = Math.atan2(knob._y - shaft._y,knob._x - shaft._x) * 180 / 3.141592653589793;
  77.       }
  78.    }
  79.    else
  80.    {
  81.       var OBJECTO = _root["GEARCHECK" add Math.ceil(data1.g / 2)]["G" add (4 - data1.g % 2)];
  82.       joystick.knob._x = OBJECTO._x + _root["GEARCHECK" add Math.ceil(data1.g / 2)]._x - joystick._x;
  83.       joystick.knob._y = OBJECTO._y + _root["GEARCHECK" add Math.ceil(data1.g / 2)]._y - joystick._y;
  84.       shaft._xscale = Math.sqrt((knob._x - shaft._x) * (knob._x - shaft._x) + (knob._y - shaft._y) * (knob._y - shaft._y));
  85.       shaft._rotation = Math.atan2(knob._y - shaft._y,knob._x - shaft._x) * 180 / 3.141592653589793;
  86.    }
  87. }
  88.