home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 108
/
jogo-disk-108.iso
/
Games
/
rush_hour.swf
/
scripts
/
__Packages
/
Car2.as
< prev
next >
Wrap
Text File
|
2010-05-15
|
2KB
|
82 lines
class Car2 extends Vehicle
{
var cartype = "car2";
var size = [1,0];
function Car2()
{
super();
}
function onPress()
{
var _loc4_ = this._parent.possibleMoves(this);
var min_x = this.getPossibleX(_loc4_[0]);
var max_x = this.getPossibleX(_loc4_[1]) - this.spacing * this.size[0];
var mousehelper = this._xmouse;
this.onEnterFrame = function()
{
var _loc2_ = undefined;
if(this._parent._xmouse - mousehelper >= min_x && this._parent._xmouse - mousehelper <= max_x)
{
_loc2_ = this._parent._xmouse - this._x - mousehelper;
}
else if(this._parent._xmouse - mousehelper < min_x)
{
_loc2_ = min_x - this._x;
}
else if(this._parent._xmouse - mousehelper > max_x)
{
_loc2_ = max_x - this._x;
}
var _loc3_ = _loc2_ / 2;
var _loc4_ = Math.round(((this._x + _loc2_) / this.spacing + 2 * (this._y + _loc3_) / this.spacing) / 2);
this._x += _loc2_;
this._y += _loc3_;
this.moveChildren(_loc2_,_loc3_);
this.adjustDepth();
this.xpos = _loc4_;
};
}
function adjustDepth()
{
_root.adjustDepth(this);
var _loc3_ = 1;
while(_loc3_ <= this.size[0])
{
_root.adjustDepth(this["child" + _loc3_]);
_loc3_ = _loc3_ + 1;
}
}
function moveChildren(xmove, ymove)
{
var _loc2_ = 1;
while(_loc2_ <= this.size[0])
{
this["child" + _loc2_]._x += xmove;
this["child" + _loc2_]._y += ymove;
_loc2_ = _loc2_ + 1;
}
}
function onRelease()
{
super.onRelease();
var _loc4_ = 1;
while(_loc4_ <= this.size[0])
{
this["child" + _loc4_]._x = this.spacing * (this.xpos + _loc4_ + this.ypos);
this["child" + _loc4_]._y = this.spacing / 2 * (this.xpos + _loc4_ - this.ypos);
_root.adjustDepth(this["child" + _loc4_]);
_loc4_ = _loc4_ + 1;
}
}
function onUnload()
{
var _loc2_ = 1;
while(_loc2_ <= this.size[0])
{
this["child" + _loc2_].swapDepths(100000);
this["child" + _loc2_].removeMovieClip();
_loc2_ = _loc2_ + 1;
}
}
}