Maze Tower Defense AI

I am trying to create a tower defense game where the player can place towers anywhere on the stage. Therefore, there is no set path for the enemies to follow, as the map is always changing. I was able to program the enemies to find their way through the maze of towers using the following code:


package  {
	public class MazeSolver {
		public static var maze;
		public function MazeSolver() {
		}
		// SOLVES THE MAZE--------------------------------------
		public static function solve(m:Array,row:int,col:int):Array {
			maze=copyArray(m);
			findPath(row,col);
			return maze;
		}
		// RECURSIVELY FINDS A PATH THROUGH THE MAZE------------
		public static function findPath(row:int,col:int):Boolean {
			if (row<0 || row>=maze.length || col<0 || col>=maze[0].length)
				return false;
			if (col==maze[0].length-1)
				return true;
			if (maze[row][col]!==0)
				return false;
			maze[row][col]=9;
			if (findPath(row,col+1)) return true;
			if (findPath(row+1,col)) return true;
			if (findPath(row-1,col)) return true;
			if (findPath(row,col-1)) return true;
			maze[row][col]=0;
			return false;
		}
		// COPIES ARRAY AND RETURNS RESULT---------------------
		public static function copyArray(oldArray:Array):Array {
			var newArray:Array=new Array();
			for (var i:int=0; i<oldArray.length; i++) {
				var row:Array=new Array();
				for (var j:int=0; j<oldArray[0].length; j++) {
					if (oldArray*[j]) row.push(oldArray*[j]);
					else row.push(0);
				}
				newArray*=row;
			}
			return newArray;
		}
	}
}

This works just fine. The enemies call the static function solve and pass as a parameter the grid of the maze. A copy of the array is made and passed to the findPath function, which recursively edits it to find a way to the the exit using 9s. The new array with the path is then returned to the enemy and it simply follows the string of 9s.

However, when there is an instance where there is a block of empty spaces (sometimes 10 by 10), there are too many cases to follow and the .swf freezes. I know using recursion might not be the best solution to this problem, but what can I do to fix this? Thank you in advance.