Sammo
12-19-2006, 02:03 PM
MovieClip.prototype.move = function(direction, speed) {
switch (direction) {
case "up":
this._y -= speed;
break;
case "right":
this._x += speed;
break;
case "down":
this._y += speed;
break;
case "left":
this._x -= speed;
break;
}
}
// allows:
hero_mc.move("left", 5);
Just to make your code that bit more readable and DRY.
switch (direction) {
case "up":
this._y -= speed;
break;
case "right":
this._x += speed;
break;
case "down":
this._y += speed;
break;
case "left":
this._x -= speed;
break;
}
}
// allows:
hero_mc.move("left", 5);
Just to make your code that bit more readable and DRY.