flash on 2009-6-16

by set0
♥0 | Line 68 | Modified 2009-06-16 23:05:30 | 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/aTII
 */

package  
{
	import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
	
    [SWF(width=465, height=465, frameRate=60, backgroundColor=0xffffff)]
    public class FlashTest6 extends Sprite
	{
		private var bar_list:Array = [];
		private var buffer:BitmapData = new BitmapData(465, 465, false);
		private var screen:Bitmap = new Bitmap(buffer);
		
		public function FlashTest6()
		{
			addChild(screen);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, makeBar);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		public function makeBar(e:Event):void
		{
			bar_list.push(new Bar(stage.mouseX, stage.mouseY));
		}
		
		private function onEnterFrame(e:Event):void
		{
			bar_list.push(new Bar(stage.mouseX, stage.mouseY));
			
			var max:int = bar_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(bar_list[i].bmp, bar_list[i].bmp.rect, new Point(bar_list[i].x, bar_list[i].y));
				if (bar_list[i].moveBar() === false) {
					bar_list.splice(i, 1);
					i--;
					max--;
				}
			}
		}
	}
	
}

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

class Bar
{
    public var bmp:BitmapData;
	public var init_x:Number;
	public var init_y:Number;
	public var x:Number;
	public var y:Number;
	public var count:Number;

    public function Bar(x:Number, y:Number)
    {
        this.bmp = new BitmapData(2, 2, false, 0x000000);
		this.x = x;
		this.y = y;
		this.init_x = x;
		this.init_y = y;
		this.count = 1;
    }
	
	public function moveBar():Boolean
	{
		this.x = Math.cos(this.count * Math.PI / 180) * this.count * 0.3 + this.init_x;
		this.y = Math.sin(this.count * Math.PI / 180) * this.count * 0.3 + this.init_y;
		
		this.count++;
		
		if (this.x >= 1000 || this.y >= 1000) {
			return false;
		}
		
		return true;
	}
}