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 HaraMakoto 25 Mar 2009
package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.Point;
	
	[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="60")]

	public class Hirogari extends Sprite
	{
		private var PM:ParticleMaster;
		private var bmp:Bitmap;
		private var bmpData:BitmapData;
		private var base:Sprite = new Sprite();
		private var fcounter:uint = 0;
		
		public function Hirogari()
		{
			addEventListener(Event.ADDED_TO_STAGE, _addStage);
			
		}
		private function _addStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, _addStage);
			
			bmpData = new BitmapData( stage.stageWidth, stage.stageHeight,true, 0xFFFFFF );
			bmp = new Bitmap( bmpData );
			addChild( base );
			addChild( bmp );
			
			PM = new ParticleMaster();
			
			base.addChild( PM );
			PM.x = stage.stageWidth/2;
			PM.y = stage.stageHeight/2;
			
			addEventListener( Event.ENTER_FRAME, _onEnterFrame );
		}
		
		private function _onEnterFrame(e:Event):void
		{
			bmpData.draw( base,null,null );
			//var blr:BlurFilter = new BlurFilter(2,2,1);
			//bmpData.applyFilter(bmpData,bmpData.rect, new Point(0,0),blr);
			if(fcounter%120==0) PM._putPerticle(null);
			fcounter++;
		}
		
	}
}
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.Shape;
	import caurina.transitions.Tweener;
	

class ParticleMaster extends Sprite
	{
		private var pointsArray:Array = new Array();
		private var particleArray:Array = new Array();
		private var pointsNum:uint = 20; //ポイント数
		private var c:Number = 0.04;
        private var n:Number = 0.0;
        private var d:Number = 0.8;
        private var shape:Shape = new Shape();
        private var cnt:uint = 0;
        private var myColor:Number;
		
		public function ParticleMaster()
		{
			super();
			addChild( shape );
			addEventListener(Event.ADDED_TO_STAGE, _addStage);
			setPoints();
		}
		
		private function _addStage(e:Event):void		
		{
			myColor = 0x000000;
			removeEventListener(Event.ADDED_TO_STAGE, _addStage);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, _putPerticle);
			addEventListener(Event.ENTER_FRAME, _onEnterFrame);
		}
		
		public function _putPerticle(e:MouseEvent):void
		{
			myColor = 0xFFFFFF * Math.random();
			this.x = stage.stageWidth * Math.random();
			this.y = stage.stageHeight * Math.random();
			for( var i:uint=0; i<pointsNum; i++ )
			{
				particleArray[i].init();
				particleArray[i].raranger();
			}
		}
		
		private function setPoints():void
		{
			for( var i:uint=0; i<pointsNum; i++ )
			{
				pointsArray.push( {x:0, y:0} );
				particleArray.push( new Particle() );
				particleArray[i].init();
				particleArray[i].raranger();
			}
		}
		
		private function _onEnterFrame(e:Event):void
		{
			n += d;
			shape.graphics.clear();
			shape.graphics.beginFill( myColor, 1 );
			shape.graphics.lineStyle(1,myColor,0.02);
			for(var i:uint=0; i<pointsNum; i++)
			{
				particleArray[i]._onEnterFrame(null);
				pointsArray[i].x = (particleArray[i].r) * Math.cos( (360 * i/pointsNum) * Math.PI / 180 );
				pointsArray[i].y = (particleArray[i].r) * Math.sin( (360 * i/pointsNum) * Math.PI / 180 );
				
				var y:Number = 1;
			}
			shape.graphics.moveTo((pointsArray[pointsArray.length-1].x + pointsArray[0].x) / 2, (pointsArray[pointsArray.length-1].y + pointsArray[0].y) / 2);
			var pt1:Object;
			var pt2:Object;
			for(i=0; i<pointsNum; i++)
			{
				
				if(i==0) {
					//shape.graphics.moveTo( pointsArray[i].x, pointsArray[i].y );
				} else {
					pt1 = pointsArray[i-1];
					pt2 = pointsArray[i];
					//shape.graphics.lineTo( pointsArray[i].x, pointsArray[i].y );
					shape.graphics.curveTo( pt1.x, pt1.y, (pt1.x+pt2.x)/2, (pt1.y+pt2.y)/2 );
				}
			}
			//shape.graphics.lineTo( pointsArray[pointsNum-1].x, 0 );
			pt1 = pointsArray[pointsArray.length-1];
			pt2 = pointsArray[0];
			shape.graphics.curveTo(pt1.x,pt1.y, (pt1.x+pt2.x)/2, (pt1.y+pt2.y)/2 );
			shape.graphics.endFill();
			cnt++;
		}
		
		
	}


class Particle extends Sprite
	{
		public var nx:Number;
		public var ny:Number;
		public var vx:Number;
		public var vy:Number;
		public var r:Number;
		public var rv:Number;
		public var rvDeccel:Number;
		public var rarange:Number;
		public var pluser:Number;
		private var minX:Number, minY:Number, maxX:Number, maxY:Number;
		
		public function Particle()
		{
			super();
			this.x = 0;
			this.y = 0;
		}
		
		public function raranger():void
		{
			rarange = 0.1;
			//拡大係数は拡大後縮小
			Tweener.addTween( this, {pluser:0.5, time:1, transition:"easeOutQuint"} );
			Tweener.addTween( this, {pluser:0, delay:1, time:10, transition:"easeOutQuint", onComplete:removeFrame} );
			
			//ランダム係数も拡大後縮小だが、落とした最初は丸くしたいので少しずらす
			Tweener.addTween( this, {rarange:3, time:1, delay:0.5, transition:"easeOutQuint"} );
			Tweener.addTween( this, {rarange:0, time:0.2, delay:1.5, transition:"easeOutQuint"} );
		}
		
		private function removeFrame():void
		{
			
		}
		
		
		public function _onEnterFrame(e:Event):void
		{
			rv = rv * rvDeccel + Math.random() * rarange + pluser;
			r += rv;
			vx = Math.cos( r * Math.PI / 180 ) * 20;
			vy = Math.sin( r * Math.PI / 180 ) * 20;
			nx += vx;
			ny += vy;
			this.x = nx;
			this.y = ny;
		}
		
		/**
		 * init
		 */
		public function init():void
		{
			//nx = 0;
			//ny = 0;
			vx = 0;
			vy = 0;
			minX = 0;
			minY = 0;
			maxX = 500;
			maxY = 500;
			r = 0;
			rv = 1;
			rvDeccel = 0.8;
			rarange = 0.1;
			pluser = 0.1;
		}
		
	}