In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Polar Distribution

Get Adobe Flash player
by homiho 04 Mar 2010
/**
 * Copyright homiho ( http://wonderfl.net/user/homiho )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5ouh
 */

// forked from shapevent's Polar Distribution
package {

	import flash.display.*;
	import flash.events.*;
        import flash.text.*;


	[SWF(width = 500, height = 500)]

       public class PolarDist extends MovieClip {
		private var dotNum:int;
		private var dotRad:Number;
		private var txt:TextField;


               public function PolarDist(){
                  // init
			dotNum = 1000;
			dotRad = 0.5;
			
			x = y = 150
			 
			
			txt = TextField(addChild(new TextField()));
			
			txt.text = "Click the stage to refresh";
			
			txt.autoSize = "left";
			txt.x = txt.y = -120
			txt.border = true;
			txt.background = true;
			
			txt.backgroundColor = 0xFFFFFF;
			
			// extra stuff to display what the functions can do
			stage.addEventListener(MouseEvent.CLICK, onDrawAll);
			
			onDrawAll();
			
			
			
			// main part from the video 
			
			
			

               }
               // private methods

		private function onDrawAll(evt:Event=null):void{
			graphics.clear();
			for (var i:int = 0; i<9; i++){
				var m:Number;
			
				var rad:Number = 120;
				var xp:Number = i % 3 * rad
				var yp:Number = int(i / 3) * rad
			
				var type:int = int(Math.random() * 4);
				if (type == 0){
				  makeShape(xp, yp, rad-60, Math.random() , 1);
				}else if (type == 1){
				   makeShape(xp, yp, rad-60, 1,  Math.random());
				}
				else if (type == 2){
				   m = Math.random() * 2;
				   makeShape(xp, yp, rad-Math.random()*120, m, m);
				}
				else if (type == 3){
				   m = Math.random() * 2;
				   makeShape(xp, yp, rad-Math.random()*120, m, m/2);
				}
			}
		}
		private function makeShape(xp:Number, yp:Number, 
						   maxRad:Number = 100,m0:Number=1, 
						   m1:Number=1):void{
			var polarX:Number;
			var polarY:Number;
			var radius:Number;
			graphics.lineStyle(0, 0);
			var theta:Number = Math.random() * Math.PI * 2;
			for (var i:int = 0; i<dotNum; i++){
				radius = Math.random() * maxRad
				polarX = xp + radius * Math.cos(theta * m0);
				polarY = yp + radius * Math.sin(theta * m1);
				theta += 0.1;
				 
				makeDot(polarX, polarY);
				
			}
		}
		private function makeDot(xp:Number, yp:Number, fillColor:uint = 0x000000):void{
			graphics.beginFill(fillColor);
			graphics.drawCircle(xp, yp, dotRad);
			graphics.endFill();
		}
		

       }

}