Help with game like checkers

I am trying to do something like the jump over enemies in checkers.
here’s a piece of code to check if a player tries to jump two tiles forward and if there’s another player or an enemy between, and if it has a stick in that direction:


[LEFT]if (y-cursorY == 2 && cursorX-x == 0 && players['p'+player]['c'+char].sticks['n'] && board[cursorY+1][cursorX][2]) {
    success = true;
}[/LEFT]
 

cursorY is the y direction here I try to go.
cursorX is the x direction here I try to go.
x is my current x direction.
y is my current y direction.

players is the array where I store all my players, so players[‘p1’][‘c2’] will be player one and character 2.
the sticks array is where I store all sticks of this character in 8 directions, so ‘n’ is north.

how can I make it jump over two or more characters?
I mean I need something like path finding which will find the path to jump over other characters.
I tried this:
Code:

   
[LEFT]function make_path(ob) {
    game.path = [];
    while (ob.parentx != null) {
        game.path[game.path.length] = ob.x;
        game.path[game.path.length] = ob.y;
        ob = path["node_"+ob.parenty+"_"+ob.parentx];
    }
}
function findPath(startx, starty, targetx, targety, player, char) {
    path = {};
    path.Unchecked_Neighbours = [];
    path.done = false;
    path.name = "node_"+starty+"_"+startx;
    path[path.name] = {x:startx, y:starty, visited:true, parentx:null, parenty:null};
    path.Unchecked_Neighbours[path.Unchecked_Neighbours.length] = path[path.name];
    while (path.Unchecked_Neighbours.length>0) {
        var N = path.Unchecked_Neighbours.shift();
        if (N.x == targetx and N.y == targety) {
            //make_path(N);
            path.done = true;
            break;
        } else {
            N.visited = true;
            if (players['p'+player]['c'+char].sticks['e'] && x+1<=5) {
                addNode(N, N.x+1, N.y);
            }
            if (players['p'+player]['c'+char].sticks['w'] && x-1>=0) {
                addNode(N, N.x-1, N.y);
            }
            if (players['p'+player]['c'+char].sticks['s'] && y+1<=6) {
                addNode(N, N.x, N.y+1);
            }
            if (players['p'+player]['c'+char].sticks['n'] && y-1>=0) {
                addNode(N, N.x, N.y-1);
            }
        }
    }
    if (path.done) {
        delete path;
        return true;
        trace("success");
    } else {
        delete path;
        return false;
    }
}

[/LEFT]
  

I call it like this:

    
[LEFT]success = findPath(x, y, cursorX, cursorY, player, char);
if (success) {
    //execute code
}

[/LEFT]
  

but it stucks and asks me to abort the script.
if you need more info ask me, I just don’t know how to do it.
thanks.