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: コンペイトウみたいだったりウィルスみたいだったり

//////////////////////////////////////
*
* copyright 2010 glasses factory
*		(http://glasses-factory.net)
* @autor YAMAGUCHI EIKICHI
* 
* 2010 2010/01/06
* 
* 3日目
* ちょっとだけマウスインタラクションつけてみた
*
/
///////////////////////////////////
/**
 * Copyright glasses_factory ( http://wonderfl.net/user/glasses_factory )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ftCP
 */

// forked from glasses_factory's コンペイトウみたいだったりウィルスみたいだったり
/*//////////////////////////////////////
*
* copyright 2010 glasses factory
*		(http://glasses-factory.net)
* @autor YAMAGUCHI EIKICHI
* 
* 2010 2010/01/06
* 
* 3日目
* ちょっとだけマウスインタラクションつけてみた
*
/*//////////////////////////////////////

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class Study1 extends Sprite
	{
		/*//////////////////////////////////////
		/*	public variables
		/*//////////////////////////////////////
		
		
		/*//////////////////////////////////////
		/*	getter
		/*//////////////////////////////////////
		
		
		/*//////////////////////////////////////
		/*	setter
		/*//////////////////////////////////////
		
		
		/*//////////////////////////////////////
		/*	public methods
		/*//////////////////////////////////////
		
		//Constractor
		public function Study1()
		{
			super();
			init();
                        //試しに2回呼び出してみたら綺麗?だったので今回だけ笑
                        init();
		}
		
                public function init():void
		{
			_buyo = new BuyoBuyo();
			addChild( _buyo );
			_buyo.x = stage.stageWidth * 0.5;
			_buyo.y = stage.stageHeight * 0.5;
			
			addEventListener( Event.ENTER_FRAME, enterFrameHandler );
		}
		
		/*//////////////////////////////////////
		/*	private methods
		/*//////////////////////////////////////
		
		private function enterFrameHandler( e:Event ):void
		{
			var i:int = 0;
			
			while( i < _buyo.ptVect.length )
			{
				var p:Particle = _buyo.ptVect[i];
				
				var dmx0:Number = _buyo.mouseX - _tmpMX;
				var dmy0:Number = _buyo.mouseY - _tmpMY;
					
				var dmx:Number = p.x - _buyo.mouseX;
				var dmy:Number = p.y - _buyo.mouseY;
				
				var dist:Number = Math.sqrt( dmx * dmx + dmy * dmy );
				if( dist < 50 )
				{
					p.vx += dmx0 * 0.05 * ( 100 - dist ) / 100;
					p.vy += dmy0 * 0.05 * ( 100 - dist ) / 100;
				}
				p.x += p.vx * 0.3 * 0.97;
				p.y += p.vy * 0.3 * 0.97;
				
				p.x += (p.tmpX - p.x ) * 0.05;
				p.y += (p.tmpY - p.y ) * 0.05;
				++i;
			}
			_tmpMX = _buyo.mouseX;
			_tmpMY = _buyo.mouseY;
			_buyo.draw();
		}
		
		
		/*//////////////////////////////////////
		/*	private variables
		/*//////////////////////////////////////
		
		private var _buyo:BuyoBuyo;
		
		private var _tmpMX:Number;
		
		private var _tmpMY:Number;
	}
}
import flash.display.Graphics;
import flash.display.Sprite;

class BuyoBuyo extends Sprite
{
	public function BuyoBuyo()
	{
		_col = Math.random() * 0xffffff;
		
		ptVect = new Vector.<Particle>();
		
		var p0:Particle = new Particle( Math.cos( 0 ) * _radius, Math.sin( 0 ) * _radius );
		var i:uint = 1;
		while( i < PT_NUM )
		{
			var angle:Number = Math.PI * 2 / PT_NUM * i;
			var rad:Number = _radius + ( Math.random() * _degree - _degree / 2 );
			var p:Particle = new Particle( Math.cos( angle ) * rad, Math.sin( angle ) * rad);
			ptVect.push( p );
			i++;
		}
		
		this.cacheAsBitmap = true;
		this.blendMode = "multiply";
		draw();
	}
	
	public function draw():void
	{
		var g:Graphics = this.graphics;
		g.clear();
		g.beginFill( _col );
		g.moveTo( (ptVect[ptVect.length -1].x + ptVect[0].x ) * 0.5 , ( ptVect[ptVect.length - 1].y + ptVect[0].y) * 0.5 );
		
		var i:int = 0;
		while( i < PT_NUM )
		{
			g.curveTo( 
				ptVect[i % ptVect.length].x, ptVect[i % ptVect.length].y, 
				( ptVect[i % ptVect.length].x + ptVect[(i + 1) % ptVect.length].x) * 0.5,
				( ptVect[i % ptVect.length].y + ptVect[(i + 1) % ptVect.length].y ) * 0.5 ); 
			++i;
		}
		g.endFill();
	}
	
	private const PT_NUM:uint = 60;
	
	public var ptVect:Vector.<Particle>;
	
	private var _radius:Number = 200;	
	private var _degree:Number = _radius / 8;
	
	private var _col:uint;
}

class Particle
{
	public var x:Number = 0;
	public var y:Number = 0;
	public var tmpX:Number = 0;
	public var tmpY:Number = 0;
	public var vx:Number = 0;
	public var vy:Number = 0;
	
	public function Particle( xx:Number, yy:Number)
	{
		x = tmpX = xx;
		y = tmpY = yy;
	}
}