package {
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	
	public class LoadingMain extends MovieClip {
		public static const ENTRY_FRAME:Number = 3;
		public static const DOCUMENT_CLASS:String = 'Main';
		
		public function LoadingMain() {
			//super();
			//stop();
			loadingMovie.loaderText.text = 0 + "%";
			loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
		}
		
		private function progressHandler(event:ProgressEvent):void {
			
			var bytesTotal = loaderInfo.bytesTotal;
			var bytesLoaded = loaderInfo.bytesLoaded;
			loadingMovie.gotoAndStop(Math.floor(bytesLoaded*100/bytesTotal));
			loadingMovie.loaderText.htmlText = "Loading " + Math.floor(bytesLoaded*100/bytesTotal) + "%";
			loadingMovie.loaderText.autoSize = TextFieldAutoSize.CENTER;
		}
		
		private function completeHandler(event:Event):void {
			gotoAndStop(2);
			//main();
		}
		/*
		private function main():void {
			var programClass:Class = loaderInfo.applicationDomain.getDefinition(LoadingMain.DOCUMENT_CLASS) as Class;
			var program:Sprite = new programClass() as Sprite;
			addChild(program);
			
		}*/
		
	}
}