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

Simple particles 2 (100k)

its cool when you make a square around the center
/**
 * Copyright Thy ( http://wonderfl.net/user/Thy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/A4dj
 */

// its cool when you make a square around the center
package {
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.geom.Rectangle;
    //
    import flash.geom.ColorTransform;
    public class Main extends Sprite 
    {
    	
    		// number of particles and the Vector for them
    		private var num:uint = 100000
    		private var parts:Vector.<Part> = new Vector.<Part>(num)
    		// Bitmap and it's Data
    		private var B:Bitmap
    		private var D:BitmapData
    		// temp Part
    		private var p:Part
    		// var used for fill the Data
        private var R:Rectangle
    	
        public function Main() 
        {
        		// init the Bitmap and it's Data
            D = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0)
            B = new Bitmap(D, "auto", true)
            R = D.rect
            stage.addChild(B)
            // init particles
            initPart()
            // enterFrame listener
            stage.addEventListener(Event.ENTER_FRAME, ef)
        }
        
        
        private function initPart():void
        {
        		// temp uint (count)
        		var i:uint = 0
        		// create the first particle
        		p = new Part()
        		parts[0] = p
        		// temp var stage width, stage height
        		var w:Number = stage.stageWidth, h:Number = stage.stageHeight
        		// create others particles
        		
        		while(++i < num)
        		{
        			p = new Part(Math.random()*w,Math.random()*h)
        			parts[i] = p
        			// assign some reference, for the looping process
        			parts[i-1].next = p
        		}
        }
        
        // temp Number for position storeage
        private var X:Number, Y:Number;
        private var col:ColorTransform = new ColorTransform(.9,1,1,.99)
        private function ef(e:Event = null):void
        {
        		// lock, for performace
        		D.lock()
        		// 'clear' the Data
        		D.colorTransform(R, col)   //D.fillRect(R, 0)
        		// process for the first particle
        		p = parts[0]
        		D.setPixel((X = p.x += (mouseX - p.x)), Y = p.y += (mouseY - p.y), 0xFFFFFF)
        		// process for others particles
        		while( (p = p.next) != null)
        		{
        			D.setPixel(X = p.x += (X - p.x)*.3, Y = p.y += (Y - p.y)*.3, 0xFFFFFF)
        		}
        		// finally nlock
        		
        		D.unlock()
        }
    }
}

class Part
{
	public var x:Number, y:Number
	public var next:Part
	
	public function Part(x:Number = 0, y:Number = 0)
	{
		this.x = x
		this.y = y
	}
}