 # Eermm... a little help please ("pathfinding")

``````
map = [
[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1]
]
waypoints = [];

function clicks ():Array {
trace(newXY);
waypoints.push(this.Names);
if(waypoints.length>2) {
waypoints = [];
}
if(waypoints.length=1) {
x1=waypoints;
x2=waypoints;
y1=waypoints;
y2=waypoints;
xDis = Math.abs(x1-x2);
yDis = Math.abs(y1-y2);
newXY = [];
trace(newXY);
if(x1<x2 || x1==x2 ) {
count = 0;
for(i=x2;i<x1+1;i++);
count++;
newX[count] = i;
}
if(x2<x1 ) {
count = 0;
for(i=x1;i<x2+1;i++);
count++;
newX[count] = i;
}
if(y1<y2 || y1==y2 ) {
count = 0;
for(i=y2;i<y1+1;i++);
count++;
newY[count] = i;
}
if(y2<y1 ) {
count = 0;
for(i=y1;i<y2+1;i++);
count++;
newY[count] = i;
}
for (i = 0; i<xDistance+1;i++){
newXY.push(newX*,y1)
}
for (i = 0; i<xDistance+1;i++){
newXY.push(x1,newY*)
}

}

return newXY;

}
function selection (xy){
for(i=0;i<xy.length+1;i++){
if (this.Names == xy*){
this.nextframe();
}
}
}

function buildMap(map) {
count=0;
for(i = 0;i<map.length;i++) {
for(j=0;j<map.length;j++) {
count++;
var tiles:MovieClip = attachMovie("tile","tile" + count,_root.getNextHighestDepth());
tiles._y = i*30;
tiles._x = j*30;
tiles.Names = [i,j]
tiles.gotoAndStop(map*[j]);
tiles.onRelease = clicks;
tiles.onEnterFrame = selection;
}
}
}

buildMap(map);

``````

basicly what it does is creates a little board that ill use when making my game. The thing is that the function clicks is supposed to make an array with the names of tiles that are than compared to the names of different tiles (if it is equal the tile colour is changed) things is, it doesnt work. Aay help would be appreciated:P. TIA

Maciek