Question about 3d perspective

Hello people of kirupa.com forums. I used the kirupa.com 3d flash tutorial about zooming figures, and I created my own file. here it is: http://www.freewebs.com/thehitman/3dtest.swf

I have two questions about this file:

  1. How can I make so that if this.z = 0,then the box movieclip stops it’s movement?
  2. How can I change the z angle, so that the box would go till the end of the wall (of the room)?

Here’s the complete code:

Origin = new Object();
Origin.x = 300;
Origin.y = 250;
box.x = -50;
box.y = 0; 
box.z = 0;
FocalLength = 300;
movebackandforward = function(){
 if (Key.isDown(Key.UP) == true) {
  this.z += 20;
 }
  if (Key.isDown(Key.DOWN) == true) {
  this.z -= 20;
 }
 var scaleRatio = FocalLength/(FocalLength + this.z);
 this._x = Origin.x + this.x * scaleRatio;
 this._y = Origin.y + this.y * scaleRatio;
 this._xscale = this._yscale = 100 * scaleRatio;
};
box.onEnterFrame = movebackandforward;