Wait, you're telling me Flash can't handle RNGing like 60 times then rendering the output of 20 odd random stars coloured circles (Seeing as, that's going to be the sum of it).
Pfft, doesn't sound like it's living up to it's name, to be honest.
Actually, its not that.
It was the 5000 iteration loop it had to go through. It had to iterate over every pixel and do a little bit of math to determine if that pixel was "inside," "outside," or "outline" of the sprite.
I cut down the operation time by half, though. So now it takes 200 ms (on this computer, which is slightly faster than my one at home) where it used to be taking 450.
(Why 5000 iterations? Well...a 96 by 72 pixel bitmap has 5084 pixels. The ships by comparison only go through 288 iterations, because A) they're smaller--24x24 or 48x48 pixels--and B) they get mirrored, only having to actually touch half the pixels in the expensive math portion).
If I am going to generate a 2700 by 2000 pixel bitmap to use as a background I'm going to need more than 60 stars. And each star is going to encompass more than 1 pixel. And they might have a "glow" to them, so if two stars are near each other, they'll need to overlap (mmm...alpha multiplication...).
Assuming each pixel is touched once, then the loop would be 5,400,000 iterations. Function overhead (ah haha, bitmapdata.setPixel
(x,y) is a function!) is pretty significant at that number of loops.
Anyway, all I'm saying is:
It will take about
5 whole seconds to generate the bitmap, at best. Which is pretty intensive for flash (as during that time the program (and its container, eg. Firefox) will be unresponsive). And at worst, it cannot take more than 14.99 seconds, or Flash will abort the operation for having taken too long (default script timeout duration is 15 seconds).