[quote=Krabex;2353483]Hey, a recent post on the forums got me thinking about particles and bitmapData. Now ive never attempted anything like this before so what i am going to show you may blind you with my hideous ideas + code, but basicly ive used the same principles as Sirsian’s Bunny code.
Anyway tbh, it has come out pretty well… but i can do about 300 particles before it chugs and i have seen 10000 particles running smooth, so my code obviously has flaws. Can someone explain to me where im going wrong and what i should be doing!? :party:
Below is a rar with all the files!!
Ty in advance guys![/quote]
Argh, I can’t open it with flash8, I guess it’s AS3.0? By looking at the classes I immidiately notice two things:
One, why do you have a pCount? If you push every particle in an array simply use pArray.Length. This is a bit more dynamic. This will not necessarily speed things up though.
Two, why do you create a new Rectangle when you’re rendering? This very slow since you do this for every particle every time it is rendered. If you have different sizes of particles atleast just save it in the constructor. Even better would be to reference it to 1 rectangle. I’m pretty sure doing this will speed things up significantly.
EDIT:
You’re also using memory with saving the xSpeed and ySpeed, even the gravity shouldn’t be a local variable. I still don’t think this is what’s causing the huge *** difference though. But I’ll keep looking 
Again, save rectangles if they’re not changing (in the render method of Emitter.as). I’m not sure what screen.fillRect and screen.applyFilter does but I’m pretty sure blur WILL take a lot of memory. Try it without the filters it’s atleast worth a shot.
Also, you’re particles are 4x4 = 16 pixels. The examples you talked about might have 1 pixel particles. Which means they wouldn’t even have to use copyPixels but rather .setPixel(x, y, color). Which could be a freaking lot faster. That might actually explain a lot xD