home *** CD-ROM | disk | FTP | other *** search
/ Champak 112 / jogo-disk-112.iso / Games / parking_zone.swf / scripts / DefineSprite_89 / frame_1 / DoAction.as
Text File  |  2010-07-14  |  825b  |  30 lines

  1. function rotateCarToFree()
  2. {
  3.    yDistance = _root["parking" + _root.freeParking]._y - this._y;
  4.    xDistance = _root["parking" + _root.freeParking]._x - this._x;
  5.    targetAngle = Math.atan2(yDistance,xDistance) * 180 / 3.141592653589793;
  6.    rotator.onEnterFrame = function()
  7.    {
  8.       deltaAngle = targetAngle - _rotation;
  9.       if(Math.abs(deltaAngle) > 10)
  10.       {
  11.          if(deltaAngle > 0 and deltaAngle < 180 or deltaAngle > -360 and deltaAngle < -180)
  12.          {
  13.             _rotation = _rotation + 10;
  14.          }
  15.          else
  16.          {
  17.             _rotation = _rotation - 10;
  18.          }
  19.       }
  20.       else
  21.       {
  22.          _rotation = targetAngle;
  23.          _root.carStoppedRotating();
  24.          delete this.onEnterFrame;
  25.       }
  26.    };
  27. }
  28. stop();
  29. this.createEmptyMovieClip("rotator",100);
  30.