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

ぶよぶよ(どっかでみたような・・・)

Get Adobe Flash player
by 178ep3 07 Nov 2009
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rFZd
 */

package
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	[SWF(backgroundColor=0xffffff, frameRate=30)]
	public class BuyoBuyo extends Sprite
	{
		private var list:Array = [];
		private var len:uint = 200;
		
		public function BuyoBuyo()
		{
			var i:uint=0;
			for(i=0; i<len; i++)
			{
				var buyobuyo:Buyo = addChild(new Buyo())as Buyo;
				buyobuyo.x = Math.random()*stage.stageWidth;
				buyobuyo.y = Math.random()*stage.stageHeight;
				list[i] = buyobuyo;
			}
			addEventListener(Event.ENTER_FRAME,loop);
		}
		
		private function loop(e:Event):void
		{
			var i:uint=0;
			for(i=0; i<len; i++)
			{
				list[i].loop();
			}
		}
	}
}
	import flash.geom.Point;
	import flash.display.Shape;
	
class Buyo extends Shape
{
		private var pt:Array = [];
		private var list:Array = [];
		private var len:uint;
		private var _rad:uint = Math.random()*50+10;
		private var _color:uint = Math.random()*0x2f+0xc0<<16 | 0x00<<8 | Math.random()*0xa0;
		private var _alpha:uint = Math.random()*4+1;
		
		public function Buyo()
		{
			var i:uint=0;
			for(i=0; i<360; i+=30)
			{
				var point:Point = Point.polar(_rad+(Math.random()*(_rad*0.2)-(_rad*0.1)),i*Math.PI/180);
				point.x = int(point.x);
				point.y = int(point.y);
				var pto:ptObject = new ptObject(point);
				pt.push(pto);
			}
			len = pt.length;
			
			list = RoundPolygon(pt);
			graphics.beginFill(_color,_alpha*0.1);
			graphics.moveTo(list[0].x,list[0].y);
			for(i=1; i<list.length-1; i+=2)
			{
				graphics.curveTo(list[i].x,list[i].y,list[i+1].x,list[i+1].y);
			}
			graphics.endFill();
		}
		
		public function loop():void
		{
			list = null;
			var i:uint=0;
			for(i=0; i<len; i++)
			{
				pt[i].loop();
			}
			
			list = RoundPolygon(pt);
			graphics.clear();
			graphics.moveTo(list[0].x,list[0].y);
			graphics.beginFill(_color,_alpha*0.1);
			for(i=1; i<list.length-1; i+=2)
			{
				graphics.curveTo(list[i].x,list[i].y,list[i+1].x,list[i+1].y);
			}
			graphics.endFill();
			rotation += Math.random()*2-1;
		}
		
		private function RoundPolygon(ptol:Array):Array
		{
			var pt:Array = ptol.slice();
			pt.push(new Point(pt[0].x,pt[0].y));
			pt.push(new Point(pt[1].x,pt[1].y));
			pt.push(new Point(pt[2].x,pt[2].y));
			
			var list:Array = [];
			for(var i:uint=1; i<pt.length-2; i++)
			{
				var pb:Point = new Point(pt[i].x,pt[i].y);
				var pn:Point = new Point((pt[i].x+pt[i+1].x)/2,(pt[i].y+pt[i+1].y)/2);
				
				list.push(pb);
				list.push(pn);
			}
			
			var p0:Point = list.shift();
			list.push(p0);
			var p1:Point = new Point(list[0].x,list[0].y);
			list.push(p1);
			
			return list
		}
}	

class ptObject extends Point
{
	private var _angle:uint = Math.random()*360;
	private var _rad:uint = Math.random()*5;
	private var _add:uint = Math.random()*10+20;
	
	public function ptObject(pt:Point)
	{
		this.x = pt.x;
		this.y = pt.y;
	}
	
	public function loop():void
	{
		this.x += Math.cos(_angle*Math.PI/180)*0.5;
		this.y += Math.sin(_angle*Math.PI/180)*0.5;
		_angle+=_add;
	}
}