package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author beisik
	 */
	public class Main extends Sprite 
	{
		[Embed(source = 'textures/font.ttf', fontName = 'life-font', mimeType = 'application/x-font-truetype', advancedAntiAliasing='true', embedAsCFF = 'false')] private const FONT: Class;
		private var start: Start;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			stage.addEventListener(KeyboardEvent.KEY_DOWN, Keys.onKeyDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, Keys.onKeyUp);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, Keys.onMouseDown);
			stage.addEventListener(MouseEvent.MOUSE_UP, Keys.onMouseUp);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, Keys.onMouseMove);
			
			start = new Start(this);
			addChildAt(start, 0);
			
			//var fps: FPS = new FPS();
			//addChild(fps);			
		}
		
		public function gameOver(scores: Number): void
		{
			start.gameOver(scores);
		}
		
	}
	
}