forked from: forked from: forked from: forked from: BitmapDataSample11
// forked from hig_an's forked from: forked from: forked from: BitmapDataSample11
// forked from hig_an's forked from: forked from: BitmapDataSample11
// forked from hig_an's forked from: BitmapDataSample11
// forked from nutsu's BitmapDataSample11
// forked from nulldesign's Liquid10000
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.ColorTransform;
import flash.display.BitmapDataChannel;
import flash.filters.BlurFilter;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(width=465,height=465,backgroundColor=0,frameRate=60)]
public class BitmapDataSample11 extends Sprite {
private var bmpdata:BitmapData;
private var particles:Array;
private var particle_number:Number = 200;
private var size:Number = 465;
private var filter:BlurFilter;
private var colortrans:ColorTransform;
public function BitmapDataSample11() {
bmpdata = new BitmapData(size, size, false, 0);
particles = new Array(particle_number);
colortrans = new ColorTransform(0.99, 0.99, 0.95);
filter = new BlurFilter(2, 2, 1);
addChild(new Bitmap(bmpdata));
for (var i:int = 0; i < particle_number; i++) {
particles[i] = new Particle(0, i + 100);
}
addEventListener( Event.ENTER_FRAME, enterframe );
}
private function enterframe( e:Event ):void {
bmpdata.applyFilter(bmpdata, bmpdata.rect, bmpdata.rect.topLeft, filter);
bmpdata.colorTransform(bmpdata.rect, colortrans);
bmpdata.lock();
for (var i:int = 0; i < particle_number; i++) {
var p:Particle = particles[i];
p.x += 1;
if (p.x == size) {
p.x = 0;
}
bmpdata.setPixel(p.x, p.y, 0xffffff);
}
bmpdata.unlock();
}
}
}
//パーティクルクラス
class Particle {
public var x:Number;
public var y:Number;
function Particle( px:Number, py:Number ) {
x = px;
y = py;
}
}