You've got plugins, so most people can't open your capx file to help. Neither can I, but I can give you some general advice.
Your goal is to move to the nearest valid position on mouse click. One way to do this is to use a helper sprite (invisible) with the custom movement behavior set to push out solids, nearest, and the solid behavior on your tilemap and areas outside your tilemap.
When you place the helper sprite on click, it should move to the nearest valid location and then you can set your pathfinding based on the new location of the helper sprite.
I'm actually not sure if the solids behavior works properly with tilemaps. If it doesn't, you'll have to overlay each solid tilemap tile with additional invisible solid helper sprites.