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: forked from: flash on 2009-8-4

規則正しく動かしてみた
Get Adobe Flash player
by iong 04 Aug 2009
/**
 * Copyright iong ( http://wonderfl.net/user/iong )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jN0h
 */

// forked from iong's forked from: flash on 2009-8-4
// forked from iong's flash on 2009-8-4

// 規則正しく動かしてみた
package
{
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.filters.BlurFilter;
	import flash.geom.Point;
	import flash.display.DisplayObject;
	import flash.utils.setInterval;
	import flash.utils.clearInterval;

	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.Stage;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;

	[SWF(backgroundColor="#FFFFFF")]

	public class As002 extends Sprite
	{
		private var gS:Sprite;
		private var cv:BitmapData;
		private var cP:Sprite;
		private var mRBlur:BlurFilter;

		private var aryGS:Array = new Array();
		private var aryTP:Array = new Array();
		private var aryPX:Array = new Array();

		// 増やす最大数
		private var iMax:uint = 3;

		public function As002():void
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.quality   = StageQuality.LOW;
			stage.frameRate = 30;

			init();
			act();
		}

		private function init():void
		{
			cv   = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xffffff);
			cP   = new Sprite();

			makeGroup();

			mRBlur = new BlurFilter(8, 8);

			this.addChild(new Bitmap(cv));
		}

		private function act():void
		{
			stage.addEventListener(MouseEvent.CLICK, makeGroup);
			cP.addEventListener(Event.ENTER_FRAME, onEFPiece);
			this.addEventListener(Event.ENTER_FRAME, onEFRoot);
		}

		// 移動するグループ・設定を作成、動作開始
		private function makeGroup(e:Event=null):void
		{
			var gSP:Sprite = makePiece(30 + Math.round(Math.random()*100));
			var i:uint     = aryGS.length;

			gSP.name= "g"+i;
			cP.addChild(gSP);

			if(i==iMax){
				var target:DisplayObject = cP.getChildAt(0);
				cP.removeChildAt(0);
				target = null;

				aryGS.splice(0,1);
				aryTP.splice(0,1);
				aryPX.splice(0,1);

				i = aryGS.length;
			}

			aryGS.push(gSP);
			aryTP.push(Math.round(Math.random()*stage.stageWidth));
			aryPX.push(2+Math.round(Math.random()*10));
		}

		// 動作MC
		private function makePiece(n:uint):Sprite
		{
			var retVal:Sprite = new Sprite();
			var gSP:Sprite;
			for(var i:uint=1; i<=4; i++){
				gSP= new Sprite();
				gSP.name = "gSP"+i;
				gSP.graphics.beginFill(retC(), 0.3);
				gSP.graphics.drawCircle(-n/2, -n/2, n);
				retVal.addChild(gSP);
				gSP.x = (i==2) ? n: (i==4) ? -n: 0;
				gSP.y = (i==1) ? -n: (i==3) ? n: 0;
			}
			retVal.x = stage.stageWidth/2;
			retVal.y = stage.stageHeight/2;
			return retVal;
		}

		// MC移動
		private function movePiece(i:uint):void
		{
			aryGS[i].rotation += aryPX[i];
		}

		private function retC():Number
		{
			var coR:String= (55+Math.round(Math.random()*200)).toString(16);
			var coG:String= (55+Math.round(Math.random()*200)).toString(16);
			var coB:String= (55+Math.round(Math.random()*200)).toString(16);
			return parseInt("0x"+coR+coG+coB, 16)
		}

		private function onEFRoot(e:Event):void
		{
			cv.draw(cP, null, null, BlendMode.OVERLAY);
			cv.applyFilter(cv, cv.rect, new Point(), mRBlur);
		}

		private function onEFPiece(e:Event):void
		{
			for(var i:uint=0; i<aryGS.length; i++){
				movePiece(i)
			}
		}
	}

}