package clases {
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import clases.lampara
	
	public class lampara extends MovieClip{
		public var clip:MovieClip
		public var zona:MovieClip
		public var xo:int
		public var yo:int
		public var pariente:MovieClip

		public function lampara(clipPasado:MovieClip,zonaPasada:MovieClip) {
			clip= clipPasado
			zona= zonaPasada
			xo = clip.x
			yo = clip.y
			pariente = MovieClip(clip.parent)
			
			
			clip.addEventListener(MouseEvent.MOUSE_DOWN,presionado)
			clip.addEventListener(MouseEvent.MOUSE_UP,suelto)
		}
		public function presionado(e){
			pariente.addChild(clip)
			clip.startDrag()
			}
		public function suelto(e){
			clip.stopDrag()
			if(clip.hitTestObject(zona)){
				pariente.sefue()
				pariente.removeChild(clip)
				}else{
					clip.x = xo
					clip.y=yo
					}
			}

	}
	
}
