package clases
{
	import flash.display.MovieClip;
	import flash.display.Shape;
	import clases.randomicoN


	public class crearPoligono
	{

		var nn:int;
		var dn:int;
		var clip:MovieClip;
		var hipo:int;
		var colores:Array = [0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF,0xFF9900,0x666600,0x666666]
		
		public function crearPoligono(numepadorPasado:int,denominadorPasado:int,contenedor:MovieClip,radioPasado:int)
		{

			nn = numepadorPasado;
			dn = denominadorPasado;
			clip = contenedor;
			hipo = radioPasado;

			var rotacion:Number = randomicoN.randomizar(0,360)
			var col:Number =  randomicoN.randomizar(0,7)
			var angulo = 360 / dn;
			var co:Number = co = hipo*(Math.sin(angulo*Math.PI/180));
			var ca:Number = ca = hipo*(Math.cos(angulo*Math.PI/180));
			for (var i:int = 1; i<dn+1; i<i++)
			{

				var segmento:Shape = new Shape();
				segmento.graphics.lineStyle(1.2,0x000000);
				if (i < nn+1)
				{
					segmento.graphics.beginFill(colores[col],1);
				}
				else
				{
					segmento.graphics.beginFill(0xFFFFFF,1);
				}
				segmento.graphics.moveTo(0,0);
				segmento.graphics.lineTo(0,hipo);
				segmento.graphics.lineTo(co,ca);
				segmento.graphics.lineTo(0,0);
				segmento.graphics.endFill();
				segmento.rotation = angulo * i;

				clip.addChild(segmento);
				clip.rotation = rotacion;
			}


		}

	}

}