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: particleTest

Get Adobe Flash player
by hacker_zeg8llq7 06 Jan 2009
    Embed
// forked from mutast's particleTest
package 
{
	import flash.display.*;
	import flash.events.Event;
	import flash.geom.*;
	
	public class ParticleDemo extends MovieClip {

		public function ParticleDemo() {
			stage.frameRate = 30;
			addEventListener(Event.ENTER_FRAME, func1);
		}
		public function func1(event:Event):void {
			var p:Part = new Part(mouseX, mouseY, Math.random() * 11 - 6, Math.random() * -10, 1, Math.random() * 0xffffff);
			addChildAt(p,0);
		}
		
	}
}
import flash.events.Event;
import flash.display.*;
import flash.geom.*;

class Part extends MovieClip{
	private var posx:Number;
	private var posy:Number;
	private var velx:Number;
	private var vely:Number;
	private var grav:Number;
	private var col:uint;
	public function Part(num1:Number, num2:Number, num3:Number, num4:Number, num5:Number, num6:uint) {
		posx = num1;
		posy = num2;
		velx = num3;
		vely = num4;
		grav = num5;
		col = num6;
		
		var ball:Ball = new Ball();
		addChild(ball);
		x = posx;
		y = posy;
		scaleX = scaleY = Math.random() * 1.8 + 0.3;
		
		var Col:ColorTransform = ball.transform.colorTransform;
		Col.color = col;
		ball.transform.colorTransform = Col;
		
		addEventListener(Event.ENTER_FRAME, func2);
	}
	public function func2(event:Event):void {
		vely += grav;
		posx += velx;
		posy += vely;
		x = posx;
		y = posy;
		if (posx < 0 || posx > stage.stageWidth || posy > stage.stageHeight) {
			removeEventListener(Event.ENTER_FRAME, func2);
			parent.removeChild(this);
		}
	}
	
}

class Ball extends Sprite {
	public function Ball() {
		var obj:Sprite = new Sprite();
		obj.graphics.beginFill(0xffffff);
		obj.graphics.drawCircle(0, 0, 10);
		addChild(obj);
	}
}