particle test
import flash.filters.ColorTransform;
/**
* Copyright AsaToBan ( http://wonderfl.net/user/AsaToBan )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/Ana9
*/
package {
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.Bitmap;
import net.hires.debug.Stats;
//import flash.filters.ColorTransform;
[SWF(width=465, height=465, backgroundColor=0x000000, frameRate=30)]
public class Main extends Sprite{
private var vVec:Vector.<Particle>;
private var bitmapData:BitmapData;
public function Main(){
bitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000);
var bmp:Bitmap = new Bitmap(bitmapData);
addChild(bmp);
addChild(new Stats());
vVec = new Vector.<Particle>();
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onMouseMove(e:MouseEvent):void{
var pir:Particle = new Particle(stage.mouseX,stage.mouseY);
this.addChild(pir);
vVec.push(pir);
}
private function onEnterFrame(e:Event):void{
var i:int = vVec.length;
while(i)
{
i--;
var pir:Particle = vVec[i] as Particle;
pir.y += pir.iRam;
}
}
}
}
////////////////////////////////////
// particle class
///////////////////////////////////
import flash.display.Sprite;
class Particle extends Sprite {
private var px:Number;
private var py:Number;
public var iRam:int;
public function Particle(_x:Number,_y:Number){
iRam = Math.floor(Math.random()*-10);
this.graphics.beginFill(0x00CCFF);
this.graphics.drawRect(_x,_y,1,1);
this.graphics.endFill();
}
}