Find point between two and do it again and again. making grid

HI there, i’m triying to make a dinamic generated plane, that plane has a grid with lines in X and Y, by now i’m able to generate a grid clicking and dragging points to make 4 lines and i generated 2 lines between the midles of the opposites lines like this:

here is the app so far:

http://www.theguaz.com/grilla_lines.swf

U have to click and drag to make a line, try making a surface in the table.

now i have this also:

http://www.theguaz.com/sodimac/draw_lines_v2.swf

that one makes the subdivision, but now i need to make that same thing in the previous swf so when u subdivides one side that same subdivision occurs in the other 3. By now i have used the Point.interpolate funtion to find the middle point between the 2 points i mark:


var puntoIni:Array = new Array(0,0);
var puntoFin:Array = new Array(0,0);
var cardinales:Array = new Array(0,0);
contador = 0;
contaMarcas = 0;
var iniciado:Boolean = false;
var poderDibujar:Boolean = false;
var drawP = true;
//
//
var ref = this;
import flash.geom.Point;
//
#include "lmc_tween.as"
//
MovieClip.prototype.soyMarca = function():Void  {
	this._alpha = 50;
	this.useHandCursor = false;
	this.onRollOver = function():Void  {
		this.alphaTo(100, 1);
		
	};
	this.onRollOut = this.onReleaseOutside=function ():Void {
		this.alphaTo(50, 1);
		
	};
};
//

//
functionDrawLines = function (init:Array):Void {
	if (contador<4) {
		ref.onEnterFrame = function():Void  {
			puntoFin[0] = ref._xmouse;
			puntoFin[1] = ref._ymouse;
			//
			//
			ref["line_mc"+contador].removeMovieClip();
			ref.createEmptyMovieClip("line_mc"+contador, ref.getNextHighestDepth());
			ref["line_mc"+contador].lineStyle(2, 0xFFFFFF, 65);
			ref["line_mc"+contador].moveTo(init[0], init[1]);
			ref["line_mc"+contador].lineTo(puntoFin[0], puntoFin[1]);
			//
		};
		ref.attachMovie("marcame_mc", "marcame_mc"+contaMarcas, ref.getNextHighestDepth(), {_x:init[0], _y:init[1]});
		ref["marcame_mc"+contaMarcas].soyMarca();
		contaMarcas++;
		contador++;
		
	}
};
calculaMitad = function (coords_one:Array, coords_two:Array):Point {
	var point_1:Point = new Point(coords_one[0], coords_one[1]);
	var point_2:Point = new Point(coords_two[0], coords_two[1]);
	var interpolatedPoint:Point = Point.interpolate(point_1, point_2, .5);
	return (interpolatedPoint);
};
creaNuevoPunto = function (punto:Point):Void {
	var puntoNew:Point = punto;
	cardinales[contador-1] = punto;
};
//
///
var mouseListener:Object = new Object();
//
mouseListener.onMouseDown = function() {
	puntoIni[0] = ref._xmouse;
	puntoIni[1] = ref._ymouse;
	//
	functionDrawLines(puntoIni);
};
//
dibujaParalelas = function ():Void {
	if (drawP == true) {
		ref.createEmptyMovieClip("linePara_mc"+0, ref.getNextHighestDepth());
		ref["linePara_mc"+0].lineStyle(0.5, 0xFFFFFF, 35);
		ref["linePara_mc"+0].moveTo(cardinales[0].x, cardinales[0].y);
		ref["linePara_mc"+0].lineTo(cardinales[2].x, cardinales[2].y);
		//
		ref.createEmptyMovieClip("linePara_mc"+1, ref.getNextHighestDepth());
		ref["linePara_mc"+1].lineStyle(0.5, 0xFFFFFF, 35);
		ref["linePara_mc"+1].moveTo(cardinales[1].x, cardinales[1].y);
		ref["linePara_mc"+1].lineTo(cardinales[3].x, cardinales[3].y);
	}
};
//
mouseListener.onMouseUp = function() {
	if (contaMarcas<8) {
		delete ref.onEnterFrame;
		//
		//
		ref.attachMovie("marca_mc", "marca_mc"+contador, ref.getNextHighestDepth(), {_x:calculaMitad(puntoIni, puntoFin).x, _y:calculaMitad(puntoIni, puntoFin).y});
		ref.attachMovie("marcame_mc", "marcame_mc"+contaMarcas, ref.getNextHighestDepth(), {_x:puntoFin[0], _y:puntoFin[1]});
		ref["marcame_mc"+contaMarcas].soyMarca();
		creaNuevoPunto(calculaMitad(puntoIni, puntoFin));
		contaMarcas++;
	}
	if (contaMarcas == 8) {
		
		dibujaParalelas();
		ref._parent.redraw_mc._visible = true;
		ref._parent.redraw_mc.alphaTo(50, 1);
		drawP = false;
		removeListener(mouseListener)
		
	}
	trace(contaMarcas)
	
	
};
Mouse.addListener(mouseListener);
//

//
stop();


How in hell i can make a function that takes two points and makes equal intervals in every line i create ???

Thanks a lot to everyone who read this.

theguaz