package{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	public class sky extends MovieClip{
		var fart:Number = 9;
		var vinkel:int = Math.random() * 360;
		
		var yretning:Number = Math.sin(vinkel * Math.PI/180) * fart;		
		var xretning:Number = Math.cos(vinkel * Math.PI/180) * fart;

		public function sky(){
			addEventListener(Event.ADDED_TO_STAGE, onadd);
		}
		private function onadd(event:Event){
			addEventListener(Event.ENTER_FRAME, loop);
			x = Math.random() * 40;
			y = Math.random() * 40;
			
			var tilfeldigx:Number = Math.random();
			var tilfeldigy:Number = Math.random();
			if (tilfeldigx > 0.5){
				x = x * -1
			}
			if (tilfeldigx > 0.5){
				y = y * -1
			}
		}
		private function loop(event:Event){
			x += xretning;
			y += yretning;
			
			var ookning:Number = 1.5;
			
			if (yretning > 0){
				yretning += ookning;
			}
			else{
				yretning -= ookning;
			}
			if (xretning > 0){
				xretning += ookning;
			}
			else{
				xretning -= ookning;
			}
			
			if(x > 70 || x < -70 || y > 70 || y < -70){
				removeEventListener(Event.ENTER_FRAME, loop);
				this.parent.removeChild(this);
			}
		}
		
		
	}//ENDCLASS
}//END PACK