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 syunsuke 16 Jan 2009
// 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="400", height="400", backgroundColor="0xEFECE2", frameRate="30")]
	public class Meta extends Sprite 
	{
		//メンバ変数 
		private var Ball_Numbers:int = 3;
		
		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 bitmap_w:int = 300;
                private var bitmap_h:int = 300;
                private var gravity:Number = 0.1
                private var friction:Number = 0.97;
		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 , 3);
			
			canvas_sprite = new Sprite();
			canvas_sprite.x = stage_w;
			canvas_sprite.y = stage_h;
			
			canvas = canvas_sprite;
			screen = new Bitmap();
			screen.bitmapData = new BitmapData(bitmap_w , bitmap_h , true );
			screen.x = 0;
			screen.y = 0;
			
			origin = new Point(0, 0);
			screenRect = new Rectangle(0, 0, bitmap_w, bitmap_h);
			
			addChild(screen);
			
			initBalls(0x904981);
			initBalls(0x990000);
			initBalls(0xE1B64E);
			initBalls(0x65811B);
			initBalls(0xA95322);
			initBalls(0x006699);

			addEventListener(Event.ENTER_FRAME , EnterFrameHandler);
			
		}
		
                //ボールの生成
		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() * 6 + 30 , color );
				ball.alpha = 1;
				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 EnterFrameHandler(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.vy += gravity;
			        //vx *= friction;
			        //vy *= friction;
				b.x += b.vx;
				b.y += b.vy;
				if ( b.x + b.width > bitmap_w ) {
					b.vx *= -1;
					b.x = bitmap_w - b.width;
				}
				if ( b.x < stage_w_min ) {
					b.vx *= -1;
					b.x = stage_w_min;
				}
				if ( b.y + b.height > bitmap_h ) {
					b.vy *= -1;
					b.y = bitmap_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();
                                screen.scaleX = 2;
                                screen.scaleY = 2;
		}
		
	}
}
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();
		}
		
	}