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

Itomimizu

Get Adobe Flash player
by hacker_3szp8277 29 Jan 2009
    Embed
// write as3 code here..
package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.filters.ColorMatrixFilter;
	
	public class Itomimizu extends Sprite
	{
		private var bmd1:BitmapData;
		private var bmd3:BitmapData;
		
		private var msls:Array = new Array;

		private var CNT:int = 500;
		public function Itomimizu()
		{
			bmd3 = new BitmapData(465,465,false,0);
			bmd1 = bmd3.clone();
			addChild(new Bitmap(bmd3,"auto",true));
			addEventListener(Event.ENTER_FRAME,move);
			
			for(var i=0;i<CNT;i++){
				msls.push(new Missile);
			}
		}

		private const nullpt:Point = new Point;
		private const flt:ColorMatrixFilter = new 
			ColorMatrixFilter(
			[ 	1,0,0,0,0,
 				0,1,0,0,0,
 				0,0,0.99,0,0,
				0,0,0,1,0
			]);
		public function move(e:Event):void{
			bmd3.lock();
			bmd3.fillRect(bmd3.rect,0);
			bmd3.applyFilter(bmd1,bmd1.rect,nullpt,flt);
			for(var i=0;i<CNT;i++){
				msls[i].move();
				msls[i].draw(bmd3);
			}
                            bmd1 = bmd3.clone();
                            bmd3.unlock();

		}
	}
}

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

class Missile 
{
	public var x:Number;
	public var y:Number;
	public var preX:Number;
	public var preY:Number;
	public var active:Boolean;
	public var vx:Number;
	public var vy:Number;
	public var spd:Number = 4;
	public var vs:Number = 1.5;
	public var theta:Number = (60*Math.PI)/180;
	public var rad:Number;
	
	public const wait:int = 15;
	private var cnt:int;
	
	private var tails:Array;
	private const TAIL_LEN:int = 100;
	private const DIST:int = 10;
	private var target:Point
	
	private function setTarget(curX:Number,curY:Number):void{
		var rad = Math.random()*Math.PI*2;
		target = new Point(
			curX+DIST*Math.cos(rad),
			curY+DIST*Math.sin(rad)
		);
	}
	
	public function Missile()
	{
	
		x = 240;
		y = 240;
		preX = x;
		preY = y;
		var dir = Math.PI*2*Math.random();
		super();
		setTarget(x,y);
		this.x = x;
		this.y = y;
			
		this.rad = dir;
		vx = Math.cos(rad)*spd;
		vy = Math.sin(rad)*spd;
	}
	
	public function move():void{
		var distX:Number = target.x-x;
		var distY:Number = target.y-y;
		var dist:Number = Math.sqrt(distX*distX+distY*distY);
		if(dist<10){
			setTarget(x,y);
		}
		if(dist>0){
			var tVx:Number = distX/dist*spd;
			var tVy:Number = distY/dist*spd;
		}else{
			tVx = 0;
			tVy = spd;
		}

		var rVx:Number = Math.cos(theta)*vx-Math.sin(theta)*vy;
		var rVy:Number = Math.sin(theta)*vx+Math.cos(theta)*vy;

		var newVx:Number;
		var newVy:Number;
		 if(vx*tVx+vy*tVy>vx*rVx+vy*rVy){
			newVx = tVx;
			newVy = tVy;
		 }else{
		 	var lVx:Number = Math.cos(theta)*vx+Math.sin(theta)*vy;
			var lVy:Number = -Math.sin(theta)*vx+Math.cos(theta)*vy;
			if(distX*rVx+distY*rVy > distX*lVx+distY*lVy){
				newVx = rVx;
				newVy = rVy;		  
	
			}else{
				newVx = lVx;
				newVy = lVy;
			}
		}
  	  	vx = newVx;
   	 	vy = newVy;
		preX = x;
		preY = y;
		x += vx;
		y += vy;
				
	}
	private function line(bmp:BitmapData,x0:int,y0:int,x1:int,y1:int,c:Number):void{
		
		var dx:int;
		var dy:int;
		var i:int;
		var xinc:int;
		var yinc:int;
		var cumul:int;
		var x:int;
		var y:int;
		x = x0;
		y = y0;
		dx = x1 - x0;
		dy = y1 - y0;
		xinc = ( dx > 0 ) ? 1 : -1;
		yinc = ( dy > 0 ) ? 1 : -1;
		dx = Math.abs(dx);
		dy = Math.abs(dy);
		bmp.setPixel32(x,y,c);
		
		if ( dx > dy ){
			cumul = dx / 2 ;
	  		for ( i = 1 ; i <= dx ; i++ ){
				x += xinc;
				cumul += dy;
				if (cumul >= dx){
		  			cumul -= dx;
		  			y += yinc;
				}
				bmp.setPixel32(x,y,c);
			}
		}else{
	  		cumul = dy / 2;
	  		for ( i = 1 ; i <= dy ; i++ ){
				y += yinc;
				cumul += dx;
				if ( cumul >= dy ){
		  			cumul -= dy;
		  			x += xinc ;
				}
				bmp.setPixel32(x,y,c);
			}
		}
	}
	public function draw(bmd:BitmapData):void{
		line(bmd,x,y,preX,preY,0xff);
	}
		
}