package classes.matuto.particles
{
	import classes.matuto.interfaces.IDisplay;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	public class ParticleShape extends MovieClip implements IDisplay
	{
		
		
		private var widthT   		:Number;
		private var heightT			:Number;
		private var widthParticle	:int;
		private var heightParticle	:int;
		private var container		:Sprite;
		private var color			:uint;
		private var pecas			:Array;
		private var linhas			:Array;

		
		public function ParticleShape(_widthParticle:int,_heightParticle:int,_width:Number,_height:Number,_color:uint=0x000000)
		{
			
			super();
		
			widthT  				= _width;
			heightT					= _height;
			widthParticle           = _widthParticle;
			heightParticle          = _heightParticle;
			color  					= _color;
			
			inicializeContainer();
			
		}
		
		private function inicializeContainer():void
		{
			
			pecas					  = [];
			linhas					  = [];
			
			container				  = new Sprite();
			addChild(container);
			
			var auxHeigth	:Number   = 	0;
			var aux			:int 	  = 	0;

			
			while(auxHeigth<=heightT)
			{
				var linha:MovieClip  = getLinha;
				linha.y  			 = aux*heightParticle;
				container.addChild(linha);
				auxHeigth 			+= heightParticle;
				aux++;
			}

		
		}
		
		private function get getLinha():MovieClip
		{
		   
			var ret			:MovieClip = new MovieClip();
		    var tinta		:Sprite    = new Sprite();
			
			var auxWidth	:Number    =	0;
			var aux			:int 	   = 	0;
			
			while(auxWidth<=widthT)
			{
				
				tinta = new Sprite();
				tinta.graphics.beginFill(color);
				tinta.graphics.drawRect(aux*widthParticle,0,widthParticle,heightParticle);
				tinta.graphics.endFill();
				ret.addChild(tinta);	

				aux++;
				
				tinta.visible = false;
				
				auxWidth += widthParticle;
			
				pecas.push(tinta);
				
				
			}
			
			linhas.push(ret);
			
			
			return ret;
			
		}
		
		public function init():void
		{
		
	
		}
		
		public function close():void
		{
		}
		
		public function resize():void
		{
		}
		
		public function dispose():void
		{
		}
		
		
		

		//==========GET==========//
		//=======================//

		public function get getPecas():Array
		{
			
			return pecas;
			
		}
		
		public function get getLinhas():Array
		{
			
			return linhas;
			
		}
			
		
		
		//=======================//
		
		
		
	}//end class
}