package{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	public class spawn extends MovieClip{
		
		public function spawn(){
			addEventListener(Event.ADDED_TO_STAGE, onadd);
		}
		private function onadd(event:Event){
				var lagnysky:MovieClip = new skyspawn;
				addChild(lagnysky);
				
				x = Math.random()*(stage.stageWidth - 50);
				y = Math.random()*(stage.stageHeight - 50);
				
				addEventListener(Event.ENTER_FRAME, sjekkshit);
		}
		
		private function sjekkshit(event:Event){
			if(this.face.hitTestPoint(stage.mouseX, stage.mouseY, true)){
				
				var xx:Number = this.x;
				var yy:Number = this.y;
				
				removeEventListener(Event.ENTER_FRAME, sjekkshit);
				var lagnysky:MovieClip = new skyspawn;
				stage.addChild(lagnysky);
				lagnysky.x = xx;
				lagnysky.y = yy;
				
				this.parent.removeChild(this);
				
				
			}
		}
		
	
	}//END class
}//END package