package classes.matuto.particles 
{
	import classes.matuto.interfaces.IDisplay;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	/**
	 * ...
	 * @author ...
	 */
	public class ExplodePixel extends MovieClip implements IDisplay 
	{
		
		
		private var i					:int 		= 0;
		private var j					:int 		= 0;
				
		private var pixelContainer		:MovieClip  = new MovieClip();
		
		private var mc					:DisplayObjectContainer;
		private var pixelBMP			:BitmapData;
		private var bmpMC				:BitmapData;
		
		public  var pecas				:Array; 
		


		
		public function ExplodePixel(_mc:DisplayObjectContainer) 
		{
			super();
			
			mc = _mc;
			
			inicializeParticles();
		
			
		}
		
		protected function inicializeParticles():void 
		{
		
			pecas = new Array();
			
			bmpMC = new BitmapData(mc.width, mc.height,true,16777215);
			bmpMC.draw(mc);
			
			var aux1:int;
			var aux2:int;
			
			var loc1:*=Math.round(35 / 30);
			var loc2:*= Math.round(35 / 30);
			
			

			
			for (i = 0; i <= mc.width; i += 35) 
			{
				
				aux2 = 0;
				
				for (j = 0; j <= mc.height; j +=35)
				{
					
					var pixel_mc:Pixel = new Pixel();
						
					pixelBMP = new BitmapData(35, 35, true, 16777215);
					pixelBMP.copyPixels(bmpMC, new Rectangle(35 * aux1,35 * aux2,35,35), new Point(0, 0));
					pixel_mc.setUpPixel(pixelBMP);
					pixel_mc.x = i;
					pixel_mc.y = j;
					pixelContainer.addChild(pixel_mc);
					
					pecas.push(pixel_mc);
					
					aux2++;
				}
				
				aux1++;
			
			}
			
			addChild(pixelContainer);
			
			mc.visible = false;
			
		}
		
		public function init():void 
		{
		
		}
		
		public function close():void 
		{
			
		}
		
		public function resize():void 
		{
			
		}
		
		public function dispose():void 
		{
			
		}
		
	}//end class
	
	
}
	
	
