package {
	
	import flash.display.Sprite;
	import flash.utils.getDefinitionByName;
	
	internal class NextFigure {
		
		private var _blocksize:uint;
		public var _clip:Sprite;
		private var _sprites:Object;
		
		public function NextFigure(clip:Sprite, blocksize:uint, sprites:Object):void {
			_clip = clip;
			_blocksize = blocksize;
			_sprites = sprites;
		}
		
		internal function onUpdateNext( ev:TetrisEvent ):void
		{
			
			var id:Class = getDefinitionByName( _sprites[ ev.shape.label ] ) as Class;
			
			var clip:Sprite = new id();
			while ( _clip.numChildren )
			{
				_clip.removeChildAt( 0 );
			}
			_clip.addChild( clip );
			clip.x = 2 * _blocksize - clip.width * 0.5;
			clip.y = _blocksize - clip.height * 0.5;
		}
		
	}
}