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

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