home *** CD-ROM | disk | FTP | other *** search
/ Champak 108 / jogo-disk-108.iso / Games / rush_hour.swf / scripts / __Packages / Car1.as < prev    next >
Text File  |  2010-05-15  |  3KB  |  87 lines

  1. class Car1 extends Vehicle
  2. {
  3.    var cartype = "car1";
  4.    var size = [0,1];
  5.    function Car1()
  6.    {
  7.       super();
  8.    }
  9.    function onPress()
  10.    {
  11.       var _loc3_ = this._parent.possibleMoves(this);
  12.       if(this.cartype == "playercar" && _loc3_[1][1] == 5)
  13.       {
  14.          _loc3_[1][1] = 6;
  15.       }
  16.       var min_x = this.getPossibleX(_loc3_[0]);
  17.       var max_x = this.getPossibleX(_loc3_[1]) - this.spacing * this.size[1];
  18.       var mousehelper = this._xmouse;
  19.       this.onEnterFrame = function()
  20.       {
  21.          var _loc2_ = undefined;
  22.          if(this._parent._xmouse - mousehelper >= min_x && this._parent._xmouse - mousehelper <= max_x)
  23.          {
  24.             _loc2_ = this._parent._xmouse - this._x - mousehelper;
  25.          }
  26.          else if(this._parent._xmouse - mousehelper < min_x)
  27.          {
  28.             _loc2_ = min_x - this._x;
  29.          }
  30.          else if(this._parent._xmouse - mousehelper > max_x)
  31.          {
  32.             _loc2_ = max_x - this._x;
  33.          }
  34.          var _loc3_ = _loc2_ / 2;
  35.          var _loc4_ = Math.round(((this._x + _loc2_) / this.spacing - 2 * (this._y + _loc3_) / this.spacing) / 2);
  36.          this._x += _loc2_;
  37.          this._y -= _loc3_;
  38.          this.moveChildren(_loc2_,_loc3_);
  39.          this.adjustDepth();
  40.          this.ypos = _loc4_;
  41.       };
  42.    }
  43.    function adjustDepth()
  44.    {
  45.       _root.adjustDepth(this);
  46.       var _loc3_ = 1;
  47.       while(_loc3_ <= this.size[0])
  48.       {
  49.          _root.adjustDepth(this["child" + _loc3_]);
  50.          _loc3_ = _loc3_ + 1;
  51.       }
  52.    }
  53.    function moveChildren(xmove, ymove)
  54.    {
  55.       var _loc3_ = 1;
  56.       while(_loc3_ <= this.size[1])
  57.       {
  58.          this["child" + _loc3_]._x += xmove;
  59.          this["child" + _loc3_]._y -= ymove;
  60.          _root.adjustDepth(this["child" + _loc3_]);
  61.          _loc3_ = _loc3_ + 1;
  62.       }
  63.    }
  64.    function onRelease()
  65.    {
  66.       super.onRelease();
  67.       var _loc4_ = 1;
  68.       while(_loc4_ <= this.size[1])
  69.       {
  70.          this["child" + _loc4_]._x = this.spacing * (this.xpos + this.ypos + _loc4_);
  71.          this["child" + _loc4_]._y = this.spacing / 2 * (this.xpos - this.ypos - _loc4_);
  72.          _root.adjustDepth(this["child" + _loc4_]);
  73.          _loc4_ = _loc4_ + 1;
  74.       }
  75.    }
  76.    function onUnload()
  77.    {
  78.       var _loc2_ = 1;
  79.       while(_loc2_ <= this.size[1])
  80.       {
  81.          this["child" + _loc2_].swapDepths(100000);
  82.          this["child" + _loc2_].removeMovieClip();
  83.          _loc2_ = _loc2_ + 1;
  84.       }
  85.    }
  86. }
  87.