UPDATE It appears this happens with any blendmode - not just erase
I've been working on a crude lighting engine for a game of mine in Adobe AIR, written in pure AS3. How it works is there is a bitmap data the size of the screen, and at the beginning of each frame it is set to a black transparent rectangle. During that step, things can subtract from the bitmap data and then when it is drawn on the screen those areas will appear lighter.
Setting that up and everything has gone smoothly. Currently I'm messing around with a basic radial gradient from the light source, and setting that up was pretty easy
_circ.graphics.lineStyle();
_circ.graphics.beginGradientFill(GradientType.RADIAL, [0x000000, 0x000000], [.9, 0], [0, 255]);
_circ.graphics.drawCircle(0, 0, 100);
_circ.graphics.endFill()
Then to draw (well, anti-draw) it onto the bitmap data, I just do this
FP.matrix.identity();
FP.matrix.tx = x + 30;
FP.matrix.ty = y + 5;
WorldGame.darkBit.draw(_circ, FP.matrix, null, BlendMode.ERASE, null, true);
FP.matrix.identity();
FP.matrix
is just a generic global matrix (I'm using Flashpunk). Now this ALMOST works, except for one tiny problem.
If you look very closely you'll be able to see a very thin black line going around the gradient, which is so very frustrating. I have no idea what's causing it - I've tried making the gradient smaller than the circle, I've tried making it linear, tried making it a different colour. It doesn't happen on blend modes other than ERASE
as well, and as far as I can tell, it doesn't happen to non-gradients either (still erasing).
Any suggestions?