Lights page 2

27 posts

Flag Post

Sorry for the double post. Since a little demo is worth a thousand words, especially my nebulous words, here’s what I mean with multiple light sources, and the relevant code is below:

		private function moveLights(eve:MouseEvent):void
			toplight.moveAbout(mouseX, mouseY);
			leftlight.moveAbout(mouseX, mouseY);
			rightlight.moveAbout(mouseX, mouseY);
			overlay.bitmapData.fillRect(overlay.bitmapData.rect, 0x01000000);
			overlay.bitmapData.copyPixels(toplight.light.bitmapData, toplight.light.bitmapData.rect,, null, null, true);
			overlay.bitmapData.copyPixels(leftlight.light.bitmapData, leftlight.light.bitmapData.rect,, null, null, true);
			overlay.bitmapData.copyPixels(rightlight.light.bitmapData, rightlight.light.bitmapData.rect,, null, null, true);
			overlay.bitmapData.colorTransform(overlay.bitmapData.rect, new ColorTransform(1, 1, 1, -1, 0, 0, 0, 255));

Clearly, since I’m using the exact same ColorTransform every time it should be stored in a class variable and recalled from there, please don’t kill me. Don’t worry about moveAbout(), it just translates the lights about the mouse pointer, nothing to see there. In fact, the only thing worth seeing is the color of the fillrect: 0×01000000. Alpha = 1 (out of 255), RGB=0. Why? Because ColorTransform does not apply to fully transparent pixels, for some reason which must be detailed in the docs and that I would know if I wasn’t so lazy. Once again, I hope it helps.

Flag Post

Works perfectly now, thank you very much. <3