function PathfindingTool(p_map) {
  this.base = EventManager
  this.base();
  this.initialized = false;
  
  this.map = p_map;
  this.flashId = this.map.fp.flashId;
  this.active = false;
  this.destinations = [];
  
  this.uid = "PathfindingTool" + PathfindingTool._instanceCount;
  this.fp = new FlashProxy(this.uid, this.flashId, this);
  
  this.map.createPathfindingTool(this.uid);
  
  PathfindingTool._instanceCount++;
}

PathfindingTool.prototype = new EventManager();

PathfindingTool.prototype.removeDestination = function(i)
{
  this.fp.call("removeDestination", i);
}

PathfindingTool.prototype.findRoute = function(destinations)
{
  this.fp.call("findRoute", destinations);
}

PathfindingTool.prototype.addDestination = function(destination, i)
{
  this.fp.call("addDestination", destination, i)
}

PathfindingTool.prototype.removeAll = function()
{
  this.fp.call("removeAll");
}

PathfindingTool.prototype.reverce = function()
{
  this.fp.call("reverce")
}

PathfindingTool.prototype.moveDestination = function(i1,i2)
{
  this.fp.call("moveDestination", i1, i2);
}

PathfindingTool.prototype._dispatchInitialized = function()
{
  this.initialized = true;
  this.dispatchMEvent('initialized');
}

PathfindingTool.prototype._dispatchActivityChanged = function(active)
{
  this.active = active;
  this.dispatchMEvent("activityChanged", {active:this.active});
}

PathfindingTool.prototype._dispatchDestinationsChanged = function(destinations, result)
{
  var oldDestinations = this.destinations;
  this.destinations = destinations;
  result = result || false
  
  this.dispatchMEvent("destinationsChanged", {destinations:this.destinations, oldDestinations:oldDestinations, result:result});
}

PathfindingTool.prototype._dispatchLengthChanged = function(length)
{
  this.dispatchMEvent("lengthChanged", {length:length});
}

PathfindingTool.prototype._dispatchRoutingErrors = function(errors)
{
  this.dispatchMEvent("routingErrors", {errors:errors});
}

PathfindingTool._instanceCount = 0;

