flash on 2009-6-17

by set0
♥2 | Line 84 | Modified 2009-06-17 16:04:01 | MIT License
play

ActionScript3 source code

/**
 * Copyright set0 ( http://wonderfl.net/user/set0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kwLZ
 */

package  
{
	import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
	
    [SWF(width=465, height=465, frameRate=60, backgroundColor=0xffffff)]
    public class FlashTest9 extends Sprite
	{
		private var spark_list:Array = [];
		private var buffer:BitmapData = new BitmapData(465, 465, false, 0xffffff);
		private var screen:Bitmap = new Bitmap(buffer);
		
		private var top_shape:Shape;
		private var middle_shape:Shape;
		private var bottom_shape:Shape;

		public function FlashTest9()
		{
			top_shape = new Shape();
			top_shape.graphics.beginFill(0xffffff, 1.0);
			top_shape.graphics.drawCircle(30, 30, 11);
			top_shape.filters = [new BlurFilter(2, 2)];
			
			bottom_shape = new Shape()
			bottom_shape.graphics.beginFill(0x996600, 1.0);
			bottom_shape.graphics.drawCircle(30, 30, 14);
			bottom_shape.filters = [new BlurFilter(16, 16)];
			
			middle_shape = new Shape();
			middle_shape.graphics.beginFill(0x000000, 1.0);
			middle_shape.graphics.drawCircle(30, 30, 15);
			
			addChild(screen);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		private function onEnterFrame(e:Event):void
		{
			spark_list.push(new Spark(stage.mouseX, stage.mouseY, top_shape, middle_shape, bottom_shape));
			
			var max:int = spark_list.length;
			buffer.colorTransform(buffer.rect, new ColorTransform(1, 1, 1, 1, 255, 255, 255, 0));

			for (var i:int = 0; i < max; i++) {
				buffer.copyPixels(spark_list[i].bottom_bmp, spark_list[i].bottom_bmp.rect, new Point(spark_list[i].x, spark_list[i].y));
				
				if (spark_list[i].move() === false) {
					spark_list.splice(i, 1);
					i--;
					max--;
				}
			}
			
			for (i = 0; i < max; i++) {
				buffer.copyPixels(spark_list[i].middle_bmp, spark_list[i].middle_bmp.rect, new Point(spark_list[i].x, spark_list[i].y));
			}
			
			for (i = 0; i < max; i++) {
				buffer.copyPixels(spark_list[i].top_bmp, spark_list[i].top_bmp.rect, new Point(spark_list[i].x, spark_list[i].y));
			}
		}
    }
}

import flash.display.*;
import flash.geom.*;
import flash.filters.*;

class Spark
{
    public var top_bmp:BitmapData;
	public var middle_bmp:BitmapData;
	public var bottom_bmp:BitmapData;
	public var x:Number;
	public var y:Number;
	public var life:Number = 100;

    public function Spark(x:Number, y:Number, top_shape:Shape, browm_shape:Shape, bottom_shape:Shape)
    {
		this.x = x - 30;
		this.y = y - 30;
		
        this.top_bmp = new BitmapData(60, 60, true, 0xffffff);
		this.top_bmp.draw(top_shape);
			
		this.middle_bmp = new BitmapData(60, 60, true, 0xffffff);
		this.middle_bmp.draw(browm_shape);
		
		this.bottom_bmp = new BitmapData(60, 60, true, 0x000000);
		this.bottom_bmp.draw(bottom_shape);

    }
	
	public function move():Boolean
	{
		life--;
		
		if (life <= 0) {
			return false;
		}
		
		return true;
	}
}

Forked