// Path Object
// Copyright 1998 Dan Steinman
// Available at the Dynamic Duo (http://www.dansteinman.com/dynduo/)
// July 3, 1998.
// In order to use this code you must keep this disclaimer

function Path(dynlayer,name,arrayX,arrayY) {
	this.dynlayer = dynlayer.obj
	this.name = name
	this.arrayX = arrayX
	this.arrayY = arrayY
	this.loop = false
	this.speed = 30
	this.fn = null
	this.play = PathPlay
	this.slide = PathSlide
	this.pause = PathPause
	this.stop = PathStop
}
function PathPlay(loop,speed,fn) {
	if (this.active) return
	this.loop = (loop)? loop : false
	this.speed = (speed)? speed : 30
	this.fn = (fn)? fn : null
	if (!this.paused) this.i = 0
	this.active = true
	this.paused = false
	eval(this.dynlayer+"."+this.name+".slide()")
}
function PathSlide() {
	if (this.active && this.i < this.arrayX.length) {
		eval(this.dynlayer+".moveTo("+this.arrayX[this.i]+","+this.arrayY[this.i]+")")
		this.i += 1
		//setTimeout(this.dynlayer+"."+this.name+".slide()",this.speed)
		this.timer=setTimeout(this.dynlayer+"."+this.name+".slide()",this.speed)

	}
	else if (!this.paused) {
		this.i = 0
		if (this.loop && this.active) this.timer=setTimeout(this.dynlayer+"."+this.name+".slide()",this.speed)
		else {
			this.active = false
			eval(this.fn)
		}
	}
}
function PathPause() {
	if (this.active) {
		//esto lo pongo yo
		clearTimeout(this.timer);

		this.active = false
		this.paused = true
	}
}
function PathStop() {
	//esto lo pongo yo
	clearTimeout(this.timer);

	this.active = false
	this.paused = false
}
