 						}
 					}
 				}
-				if (open.a.length == 1)
+				if (open.a.length == 1||step>maxStep)
 				{
 					isFind = false;
 					break;

									{
										cost = Math.SQRT2;
									}
									var g:Number = node.g + cost;
									var h:Number = Math.sqrt((test.x-endX)*(test.x-endX)+(test.y-endY)*(test.y-endY))//Math.abs(test.x - endX) + Math.abs(test.y - endY);
									var f:Number = g + h;

			return x.f < y.f;
		}
		
		public function findPath(startX:int, startY:int, endX:int, endY:int,maxStep:int=1000000):Boolean
		{
			nowVersion++;
			var step:int = 0;
			open = new BinaryHeap(justMin);
			if (nodes[startY] && nodes[startY][startX])
			{
