131,072 Particles
65,536→131,072!
If this flash is not too heavy, you can make more particles!
/**
* Copyright 127.0.0.1 ( http://wonderfl.net/user/127.0.0.1 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mNm5
*/
package {
// 127.0.0.1
import flash.display.Sprite;
public class ManyParticles extends Sprite {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.ColorTransform;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.events.MouseEvent;
private const bmpdat:BitmapData = new BitmapData(465,465,true,0xFF000000);
private const color:ColorTransform = new ColorTransform(1,1,1,.9);
private var i:int;
private const len:int = 131072;
private const px:Vector.<Number> = new Vector.<Number>(len,true);
private const py:Vector.<Number> = new Vector.<Number>(len,true);
private const acc:Vector.<Number> = new Vector.<Number>(len,true);
private const reverse:Vector.<Boolean> = new Vector.<Boolean>(len,true);
private var _px:Number, _py:Number, _acc:Number, _ax:Number, _ay:Number, _reverse:Boolean;
private var d_x:Number, d_y:Number;
private var _mx:int, _my:int;
private const rect:Rectangle = new Rectangle(0,0,465,465);
private var angle:Number;
public function ManyParticles() {
_mx = this.mouseX;
_my = this.mouseY;
this.graphics.beginFill(0x000000);
this.graphics.drawRect(0,0,465,465);
this.addChild(new Bitmap(bmpdat));
for (i = 0; i < len; i = i + 1) {
do {
d_x = Math.random() * 800 - 400;
d_y = Math.random() * 800 - 400;
} while ((d_x * d_x + d_y * d_y) > 160000)
// Math.sqrt(d_x * d_x + d_y * d_y) > 400
px[i] = d_x + _mx;
py[i] = d_y + _my;
acc[i] = 0;
reverse[i] = false;
}
stage.addEventListener(Event.ENTER_FRAME,enter_frame);
stage.addEventListener(MouseEvent.CLICK,mouse_click);
stage.addEventListener(MouseEvent.MOUSE_MOVE,mouse_move);
}
private function enter_frame(e:Event):void {
bmpdat.lock();
bmpdat.colorTransform(rect,color);
for (i = 0; i < len; i = i + 1) {
_px = px[i]; _py = py[i], _acc = acc[i];
d_x = _px - _mx; d_y = _py - _my;
angle = Math.atan2(d_y, d_x);
if (reverse[i]) {
_acc = - _acc + .25;
if (_acc >= 0) {
reverse[i] = false;
}
} else {
_acc = _acc + .24;
}
_ax = _acc * Math.cos(angle);
_ay = _acc * Math.sin(angle);
_px = _px - _ax;
_py = _py - _ay;
if ((d_x * d_x + d_y * d_y) <= 100) {
if (!reverse[i]) {
_acc = - _acc;
reverse[i] = true;
}
}
px[i] = _px; py[i] = _py;
if (reverse[i]) {
acc[i] = - _acc;
} else {
acc[i] = _acc;
}
bmpdat.setPixel32(_px,_py,0xFFFFFFFF);
}
bmpdat.unlock();
}
private function mouse_click(e:MouseEvent):void {
for (i = 0; i < len; i = i + 1) {
do {
d_x = Math.random() * 800 - 400;
d_y = Math.random() * 800 - 400;
} while ((d_x * d_x + d_y * d_y) > 160000)
acc[i] = 0;
px[i] = d_x + _mx; py[i] = d_y + _my;
reverse[i] = false;
}
}
private function mouse_move(e:MouseEvent):void {
_mx = e.localX;
_my = e.localY;
}
}
}