as3pathfinder is a grid path finding library. It finds the shortest route from a start point to an end on a 2D grid for a given map of obstacles. The library uses the Dijkstra’s algorithm to calculate the route.

The grid used by the library can be described as a matrix, a two-dimensional array where obstacles are marked with 1 and the rest is marked as 0. The resulting route is described as an array of points.

Sample

var map:Array = [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 1, 0, 0, 0, 0, 0, 0]];

var pt:Pathfinder = new Pathfinder();           
pt.loadMap(map, 10, 10);
var path:Array = pt.getPath(new Point(1, 1), new Point(8, 8), false);   

var myShape:Shape = new Shape(); 
addChild(myShape);

myShape.graphics.lineStyle(2, 0x990000, 5);

for (var i:int=0; i < path.length; i++) {
        trace(path[i].x, path[i].y)
        myShape.graphics.lineTo(path[i].x, path[i].y);;
}
Path Finding . URL.