First i need to say that i don`t have almost any experience working with Bitmaps and BitmapData, and i am looking to change this. So today i started some particle generator class that will move particles over the stage via drawing in a Bitmap. Everything works well with low amount of particles, lets say 1000, but for my surprise when i added 10 000 particles the frame rate dropped drastically. And i am saying that since i made the same particle generator using MovieClips instead of drawing in Bitmap, the performance test i run on both classes showed that the Bitmap class with 10K particles on my PC works in around 10-12 FPS, and the MovieClip variation in around 20-21 FPS with the same amount of particles. The particles are identical and both classes are using linked list system to move the particles. So the only logical conclusion is that something is not right with the drawing function. I would appreciate any ideas or suggestions about that peace of code:
private function drawParticles(e:Event):void{
// clearing the _pZone Bitmap of the previous data
_pZone.bitmapData.fillRect(_pZone.bitmapData.rect,0);
_pZone.bitmapData.draw(_blankMc);
// drawing the particles
// The Node class extends Point and have 3 public variables
// (nextNode,_graw,_wind);
var n:Node = _firstNode;
do{
n.x += n._wind;
n.y += n._grav;
// keeping the point in bounds
if(n.x > _width || n.y > _height){
n.x = - 200 + Math.random()* (_width+200);
n.y = -100;
}
//drawing the particle in the Bitmap
//_particle is a BitmapData object
var mat:Matrix = new Matrix();
mat.translate(n.x,n.y);
_pZone.bitmapData.draw(_particle,mat);
n = n.nextNode;
}while(n.nextNode != null);
}
Regards Thovas