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 cpu_t 21 Mar 2010
    Embed
/**
 * Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3xXi
 */

package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
    import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.Matrix;
	import flash.geom.Point;
    public class FlashTest extends Sprite
	{
		private var bmpdata:BitmapData;
		private var src:Array;
		private var t:Number;
		private var sx:Number;
		private var filter:BlurFilter;
		private var list:Array;
		private var back:BitmapData;
        public function FlashTest()
		{
			bmpdata = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0);
			addChild(new Bitmap(bmpdata));
			
			back = new BitmapData(bmpdata.width, bmpdata.height, true, 0);
			
			sx = 465 * .5;
			t = 0;
			list = new Array();
			
			src = new Array();
			srcInit();
			
			filter = new BlurFilter();
			
			addEventListener(Event.ENTER_FRAME, onUpdate);
        }
		
		private function onUpdate(e:Event):void 
		{
			t++;
			bmpdata.fillRect(bmpdata.rect, 0);
			if (Math.random() < .1)
			{
				list.push( {
					x:sx + Math.cos(2*t * Math.PI / 180) * bmpdata.width * .5,
					y:0,
					r:0,
					type:Math.floor(Math.random() * 4),
					d:false
				});
			}
			var bdtop:BitmapData = new BitmapData(bmpdata.width, bmpdata.height, true, 0);
			var bdtempback:BitmapData = new BitmapData(bmpdata.width, bmpdata.height, true, 0);
			var m:Matrix = new Matrix();
			for (var i:int = 0; i < list.length; i++)
			{
				m.identity();
				with (list[i])
				{
					m.rotate(r);
					m.translate(x, y);
					if (!d)
					{
						y += 2;
						r += 2 * Math.PI / 180;
						bdtop.draw(src[type], m);
						if (Math.random() < .01) d = true;
					}
					else
					{
						bdtempback.draw(src[type], m);
						list.splice(i, 1);
						i--;
					}
				}
			}
			bdtempback.applyFilter(bdtempback, bdtempback.rect, bdtempback.rect.topLeft, filter);
			back.copyPixels(bdtempback, bdtempback.rect, bdtempback.rect.topLeft,null,null,true);
			bmpdata.copyPixels(back, back.rect, back.rect.topLeft);
			bmpdata.copyPixels(bdtop, bdtop.rect, bdtop.rect.topLeft, null, null, true);
		}
		
		private function srcInit():void
		{
			src[0] = new Sprite();
			src[0].graphics.beginFill(0xFF4000);
			src[0].graphics.drawCircle(0, 0, 25);
			src[0].graphics.drawCircle(0, 0, 22);
			src[0].graphics.endFill();
			
			src[1] = new Sprite();
			src[1].graphics.beginFill(0x0040FF);
			var command:Vector.<int> = new Vector.<int>();
			command.push(1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
			var data:Vector.<Number> = new Vector.<Number>();
			data.push( -25, -22, -22, -25, 0, -3, 22, -25, 25, -22, 3, 0, 25, 22, 22, 25, 0, 3, -22, 25, -25, 22, -3, 0);
			src[1].graphics.drawPath(command, data);
			src[1].graphics.endFill();
			
			src[2] = new Sprite();
			src[2].graphics.beginFill(0xFF40FF);
			src[2].graphics.drawRect( -25, -25, 50, 50);
			src[2].graphics.drawRect( -22, -22, 44, 44);
			src[2].graphics.endFill();
			
			src[3] = new Sprite();
			src[3].graphics.beginFill(0x40FF40);
			command = new Vector.<int>();
			command.push(1,2,2,1,2,2);
			data = new Vector.<Number>();
			data.push(0,-25, 25,22, -25,22, 0,-19, 20,19, -20,19);
			src[3].graphics.drawPath(command, data);
			src[3].graphics.endFill();
		}
    }
}