 	import flash.net.URLLoaderDataFormat;
 	import flash.net.URLRequest;
 	import flash.utils.ByteArray;
+	import flash.utils.Dictionary;
 	import flash.utils.getQualifiedClassName;
 	
 	import aerys.minko.render.resource.texture.TextureResource;

		
		protected var _textureResource	: TextureResource;
		
		public function get progress() : Signal
		{
			return _progress;

			}
		}
		
		public static function loadClass(classObject 			: Class,
										 enableMipMapping 		: Boolean = true, 
										 textureResource		: TextureResource = null) : TextureResource
		{
			var textureLoader : TextureLoader = new TextureLoader(enableMipMapping, textureResource);
			
			textureLoader.loadClass(classObject);
			
			if (!textureLoader.textureResource.contextLost.hasCallback(classTexturecontextLostHandler))
			{
				_textureResourceToClass[textureLoader.textureResource] = classObject;
				textureLoader.textureResource.contextLost.add(classTexturecontextLostHandler);
			}
			
			return textureLoader.textureResource;
		}
		
		public static function load(request				: URLRequest,
									enableMipMapping 	: Boolean = true, 
									textureResource		: TextureResource = null) : TextureResource
		{
			var textureLoader : TextureLoader = new TextureLoader(enableMipMapping, textureResource);
			
			textureLoader.load(request);
			
			if (!textureLoader.textureResource.contextLost.hasCallback(urlRequestTexturecontextLostHandler))
			{
				_textureResourceToRequest[textureLoader.textureResource] = request;
				textureLoader.textureResource.contextLost.add(urlRequestTexturecontextLostHandler)
			}
			
			return textureLoader.textureResource;
		}
		
		public static function loadBytes(bytes				: ByteArray,
										 enableMipMapping 	: Boolean = true, 
										 textureResource	: TextureResource = null) : TextureResource
		{
			var textureLoader : TextureLoader = new TextureLoader(enableMipMapping, textureResource);
			
			textureLoader.loadBytes(bytes);
			
			return textureLoader.textureResource;
		}
		
		private static function classTexturecontextLostHandler(textureResource : TextureResource) : void
		{
			TextureLoader.loadClass(_textureResourceToClass[textureResource], textureResource.mipMapping, textureResource);
		}
		private static function urlRequestTexturecontextLostHandler(textureResource : TextureResource) : void
		{
			TextureLoader.load(_textureResourceToRequest[textureResource], textureResource.mipMapping, textureResource);
		}
	}
}