Lines, Grids and trig...oh my

Hi i need some help snaping my line to every 20 px and I would like to be able to add a measure ment to each line… anyone know how this is done. any help or sugestions would be greatly appreciated!!

Thanks


i = 0;
      
MovieClip.prototype.buildPoint = function(halfWidth) { 
    this.lineStyle(1, 0x000000, 200); 
    this.beginFill(0xE6E6E6, 100); 
    this.moveTo(-halfWidth, -halfWidth); 
    this.lineTo(halfWidth, -halfWidth); 
    this.lineTo(halfWidth, halfWidth); 
    this.lineTo(-halfWidth, halfWidth); 
    this.lineTo(-halfWidth, -halfWidth); 
}; 
function drawProcess() { 
 this.createEmptyMovieClip("line" + _parent.current_line, this.getNextHighestDepth()); 
    i++; 
    xPos = _xmouse; 
    yPos = _ymouse; 
    point1._x = point2._x=xPos; 
    point1._y = point2._y=yPos; 
    point1._visible = point2._visible=true; 
    this["line" + _parent.current_line].moveTo(xPos, yPos); 
    this.onMouseMove = function() { 
        tempLine.clear(); 
        tempLine.lineStyle(2, 0xE6E6E6, 50); 
        tempLine.moveTo(xPos, yPos); 
        //if (Key.isDown(Key.SHIFT)) { 
  
  //trace(_xmouse + ' ' + _ymouse + ' ' + this._x + ' ' + this._y);
  //if (_xmouse >= 200 || _ymouse >= 200)
    //{
     
     
            if (_ymouse<=yPos-10 || _ymouse>=yPos+10) {
    
     
    
                point2._x = xPos; 
                point2._y = _ymouse; 
                tempLine.lineTo(xPos, _ymouse); 
            }
   else { 
                point2._x = _xmouse; 
                point2._y = yPos; 
                tempLine.lineTo(_xmouse, yPos); 
            }
   
    //}
    
        //} else { 
            //point2._x = _xmouse; 
           // point2._y = _ymouse; 
           // tempLine.lineTo(_xmouse, _ymouse); 
        //} 
    }; 
} 
function drawFinalLine() { 
    tempLine.clear(); 
    delete this.onMouseMove; 
 
 if (_xmouse > 0 && _ymouse > 0)
 {
 
    point1._visible = point2._visible=false; 
    this["line" + _parent.current_line].lineStyle(2, 0x000000, 100); 
    //if (Key.isDown(Key.SHIFT)) { 
        if (_ymouse<=yPos-10 || _ymouse>=yPos+10) { 
            this["line" + _parent.current_line].lineTo(xPos, _ymouse); 
        } else { 
            this["line" + _parent.current_line].lineTo(_xmouse, yPos); 
        } 
    //} else { 
        //line.lineTo(_xmouse, _ymouse); 
    //} 
    if (i>=4) { 
        i = 0; 
    } 
 trace ("line" + _parent.current_line)
 _parent.current_line++;
 
 }
} 
/*function clearMe() { 
    if (Key.isDown(Key.DELETEKEY)) { 
        this.line.clear();  
}
 
 _root.undo_btn.onPress = function() {
  _root.["line" + current_line].removeMovieClip();
  current_line--;
} 
*/
this.createEmptyMovieClip("tempLine", 2); 
this.createEmptyMovieClip("point1", 3).buildPoint(3); 
this.createEmptyMovieClip("point2", 4).buildPoint(3); 
point1._visible = point2._visible=false; 
this.onMouseDown = drawProcess; 
this.onMouseUp = drawFinalLine; 
this.onEnterFrame = clearMe;