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: モヤモヤっと

Get Adobe Flash player
by juvial 25 Dec 2008
// forked from syunsuke's モヤモヤっと
// write as3 code here..
package 
{
	import flash.display.*;
	import flash.geom.*;
	import flash.events.*;
	import flash.utils.*;
	import flash.ui.*;
	import flash.filters.*;
	
	[SWF(width="600", height="600", backgroundColor="0xFFFFFF", frameRate="30")]
	public class Meta extends Sprite 
	{
		//メンバ変数 
		private var Ball_Numbers:int = 4;
		
		private var canvas:DisplayObjectContainer;
		private var canvas_sprite:Sprite;
		private var screen:Bitmap;
		private var contener:BitmapData;
		private var screenRect:Rectangle;
		private var origin:Point;
		private var stage_w:int = stage.stageWidth;
		private var stage_h:int = stage.stageHeight;
		private var stage_w_min:int = 0;
		private var stage_h_min:int = 0;
		private var blurFilter:BlurFilter;
		
		//コンストラクタ
		public function Meta():void
		{
			trace("コンストラクタ : constract_name")
			addEventListener( Event.ADDED_TO_STAGE, init );
		}
		
		private function init(e:Event):void
		{
			trace("function : init")
			removeEventListener( Event.ADDED_TO_STAGE, init ); 
			
			stage.frameRate = 30;
			stage.scaleMode = StageScaleMode.NO_SCALE
			stage.align = StageAlign.TOP_LEFT;
			
			blurFilter = new BlurFilter(128,128);
			
			canvas_sprite = new Sprite();
			canvas_sprite.x = stage_w;
			canvas_sprite.y = stage_h;
			
			canvas = canvas_sprite;
			screen = new Bitmap();
			screen.bitmapData = new BitmapData(stage_w , stage_h , true );
			screen.x = 0;
			screen.y = 0;
			
			origin = new Point(0, 0);
			screenRect = new Rectangle(0, 0, stage_w, stage_h);
			
			addChild(screen);
			
			initBalls(0x000000);
			initBalls(0x904981);
			initBalls(0xE5E3D6);
			initBalls(0xE1B64E);
			initBalls(0x65811B);
			initBalls(0xA95322);
			
			addEventListener(Event.ENTER_FRAME , on_Enter_Frame);
			
		}
		
		private function initBalls(color:uint):void {
			trace("function : initBalls")
			for ( var i:uint = 0; i < Ball_Numbers; i++ ) {
				var ball:Ball = new Ball(Math.random() * 60 + 100 , color );
				ball.alpha = 0.2;
				ball.x = Math.random() * stage_w;
				ball.y = Math.random() * stage_h;
				ball.vx = Math.random() * 4+ 1;
				ball.vy = Math.random() * 4 + 1;
				canvas.addChild(ball);
			}
		}
		
		
		private function on_Enter_Frame(e:Event):void 
		{
			for ( var i:uint = 0; i < canvas.numChildren ; i++ ) {
				var b:Ball = canvas.getChildAt(i) as Ball;
				//b.alpha = 0.2;
				b.x += b.vx;
				b.y += b.vy;
				if ( b.x + b.width > stage_w ) {
					b.vx *= -1;
					b.x = stage_w - b.width;
				}
				if ( b.x < stage_w_min ) {
					b.vx *= -1;
					b.x = stage_w_min;
				}
				if ( b.y + b.height > stage_h ) {
					b.vy *= -1;
					b.y = stage_h  - b.height;
				}
				if ( b.y < stage_h_min ) {
					b.vy *= -1;
					b.y = stage_h_min;
				}
			}
			
			render();
		}
		
		
		private function render():void 
		{
				screen.bitmapData.lock();
				screen.bitmapData.fillRect(screenRect, 0xFFFFFF);
				screen.bitmapData.draw(canvas_sprite);
				screen.bitmapData.applyFilter(screen.bitmapData, screenRect, origin, blurFilter);
				screen.bitmapData.unlock();
		}
		
	}
}
import flash.display.Sprite;
import flash.events.MouseEvent;

	class Ball extends Sprite 
	{
		//メンバ変数 
		public var radius:Number;
		public var color:uint;
		public var vx:Number = 0;
		public var vy:Number = 0;
		
		
		//コンストラクタ
		public function Ball(radius:Number = 40 , color:uint = 0xff0000):void
		{
			trace("コンストラクタ : Ball")
			this.radius = radius;
			this.color = color;
			init();
		}
		private function init():void
		{
			trace("function : init")
			graphics.beginFill(color);
			graphics.drawCircle(0 , 0 , radius);
			graphics.endFill();
		}
		
	}