Here’s a little example that shows a how a basic setup would work. You can find more information on analyzers, maps and pathrequests in the corresponding sections.
package { import be.dauntless.astar.basic2d.BasicTile; import be.dauntless.astar.basic2d.Map; import be.dauntless.astar.basic2d.analyzers.WalkableAnalyzer; import be.dauntless.astar.core.Astar; import be.dauntless.astar.core.AstarEvent; import be.dauntless.astar.core.IAstarTile; import be.dauntless.astar.core.PathRequest; import flash.display.Sprite; import flash.geom.Point; public class GeneralTest extends Sprite { private var dataMap:Array; private var map : Map; private var astar : Astar; private var req:PathRequest; public function GeneralTest() { dataMap = [ [0,0,1,1,1,0], [0,0,0,0,1,0], [0,1,1,0,0,0], [0,0,0,0,1,0], [0,1,1,0,1,0], [1,1,0,0,0,0] ]; //create a new map and fill it with BasicTiles map = new Map((dataMap[0] as Array).length, dataMap.length); for(var y:Number = 0; y< dataMap.length; y++) { for(var x:Number = 0; x< (dataMap[y] as Array).length; x++) { map.setTile(new BasicTile(1, new Point(x, y), (dataMap[y][x]==0))); } } //create the Astar instance and add the listeners astar = new Astar(); astar.addEventListener(AstarEvent.PATH_FOUND, onPathFound); astar.addEventListener(AstarEvent.PATH_NOT_FOUND, onPathNotFound); //create a new PathRequest req = new PathRequest(IAstarTile(map.getTileAt(new Point(0, 0))), IAstarTile(map.getTileAt(new Point(5, 5))), map); //a general analyzer astar.addAnalyzer(new WalkableAnalyzer()); astar.getPath(req); } private function onPathNotFound(event : AstarEvent) : void { trace("path not found"); } private function onPathFound(event : AstarEvent) : void { trace("Path was found: "); for(var i:int = 0; i<event.result.path.length;i++) { trace((event.result.path[i] as BasicTile).getPosition()); } } } }
This will return
Path was found:
(x=0, y=0)
(x=0, y=1)
(x=0, y=2)
(x=1, y=3)
(x=2, y=3)
(x=3, y=4)
(x=4, y=5)
(x=5, y=5)
Or, graphically:

Hi!
Say please, how me create pathfind without diagonal transition?
Hi Andrew,
You have to add the FullClippingAnalyzer as documented on http://www.dauntless.be/astar/analyzers. It could be a little more clear though, so I’ll change this documentation page a little.
Thank you, very much!
But if i change analyzer on FullClippingAnalyzer, path go over ocuped tiles. Thus, the path is solved incorrectly. (
You don’t have to change it from one to another, you have to add them both:
astar.add(new WalkableAnalyzer());
astar.add(new FullClippingAnalyzer());
O! Thank you.
I am try.