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

Particles X (batu)

@author zawa
[dubflash] http://www.dubfrog.net/blog/
/**
 * Copyright dubfrog ( http://wonderfl.net/user/dubfrog )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rRUZ
 */

package {
	
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.filters.*;
	import flash.geom.*;
	import org.libspark.betweenas3.BetweenAS3;
	import org.libspark.betweenas3.easing.*;
	import org.libspark.betweenas3.events.*;
	import org.libspark.betweenas3.tweens.*;
	
	/* * @author zawa*/
	
	/* [dubflash] http://www.dubfrog.net/blog/ */
	
	[SWF(width = "465", height = "465", backgroundColor = "0x000000", fps = "60")]
	
	public class Main extends Sprite {
		private var mc:Sprite;
		private var particleAry:Array;
		private var particleMax:Number;
		private var particleSize:Number
		private var particleSpd:Number;
		private var updateCnt:Number;
		private var stw:Number;
		private var sth:Number;
		
		public function Main():void{
			
			stw = stage.stageWidth;
			sth = stage.stageHeight;
			particleAry = [];//particle格納用配列
			particleMax = 300;//particle最大数
			particleSize = 8;//particleサイズ*2
			particleSpd = 2;
			updateCnt = 0;//counter
			
			mc = new Sprite();
			addChild(mc);
			
			bgDetail();
			AddParticleCircle();
			addEventListener(Event.ENTER_FRAME, Update);
		}
		//background生成
		private function bgDetail() :void{
			var matrix:Matrix = new Matrix();
			var gpx:Graphics = mc.graphics;
			matrix.createGradientBox(stw*2, sth*1.5, 0, -stw/2, -250);
			gpx.beginFill(0x000000,1);
			//gpx.beginGradientFill(GradientType.RADIAL, [0x0099CC,0x000000], [1, 1], [0, 255], matrix);
			gpx.drawRect(0, 0, stw, sth);
			gpx.endFill();
		}
		private function AddParticleCircle() :void {
			var i:Number = 0,
			    radian:Number = Math.PI / 180,
				radius:Number = 0,
				angle:Number = 0,
				blur:BlurFilter = new BlurFilter(5, 5, 1);
			while(i<particleMax){
				i++;
				var particle:MovieClip = new MovieClip();
				particle.graphics.beginFill(Math.floor(0xFFFFFF*Math.random()), 1);
                                var rsize:Number = particleSize * Math.random() + .1;
				particle.graphics.drawCircle( -rsize/2, -rsize/2, rsize);
				particle.graphics.endFill();
				radius = Math.random() * 200;
				angle = Math.random() * 360;
				var radSinX:Number = Math.sin(radian * angle) * radius + stw/2;
				var radCosX:Number = Math.cos(radian * angle) * radius + sth/2;
				
				particle.x = radSinX;
				particle.y = radCosX;
				particle.alpha = 1;
				particle.extra = { fposX:particle.x,
				                   fposY:particle.y,
								   radian:radian,
								   angle:angle,
								   radius:radius,
								   nextRadius:radius,
								   rNum:Math.random() * particleSpd - (particleSpd/2),//angle代入値
								   cNum:Math.floor(Math.random() * 50) + 30//%cnt
								   };
				particle.filters = [blur]
				particle.blendMode = BlendMode.ADD;
				mc.addChild(particle);
				particleAry.push(particle);
			}
		}
		
		//Update
		private function Update(e:Event) :void{
			updateCnt++;
			var spx:Number,
			    spy:Number,
				radian:Number = Math.PI / 180;
			for (var i:Number = 0; i <= particleMax; i++) {
				var target:MovieClip = particleAry[i];
				if (target is MovieClip) {
					//if (updateCnt % target.extra.cNum == 0) target.extra.nextRadius = Math.random() * 200;
					target.extra.radius += (target.extra.nextRadius - target.extra.radius)*.05;
					target.extra.angle += target.extra.rNum;
					
					var tickness:Number = 105;
					if(i%2==0) spx = Math.sin(radian * updateCnt) * tickness;
					else spx = Math.cos(radian * updateCnt) * tickness;
					if(i%2==0) spy = Math.cos(radian * updateCnt) * tickness;
					else spy = Math.sin(radian * updateCnt) * tickness;
					
					var sinX:Number = Math.sin(radian * (target.extra.angle + spx)) * target.extra.radius + stw / 2;
					var cosY:Number = Math.cos(radian * (target.extra.angle + spy)) * target.extra.radius + sth / 2;
					target.x = sinX;
					target.y = cosY;
				}
			}
			
			var blur:BlurFilter = new BlurFilter(5, 5, 2);
			var bmp:BitmapData = new BitmapData(stw, sth, true, 0x808080);
			var bmpObj:Bitmap = new Bitmap(bmp);
			bmp.draw(mc);
			bmpObj.filters = [blur];
			var cbmp:BitmapData = new BitmapData(stw, sth, true, 0x808080);
			var cbmpObj:Bitmap = new Bitmap(cbmp);
			cbmp.draw(bmpObj);
			mc.addChildAt(cbmpObj, 0);
			var beTween:IObjectTween = BetweenAS3.tween(cbmpObj, { alpha:0 }, null, .3, Linear.linear);
			beTween.addEventListener(TweenEvent.COMPLETE, function() :void{
				mc.removeChild(cbmpObj);
			});
			beTween.play();
		}
	}
}