views:

538

answers:

1

Hi there,

I'm trying to remove a color from a picture imported (JPG) in Flash CS4 with AS2.

I have a bunch of JPG images loaded at launch that contain a color (flashy green 0,255,0) that I want to remove in order to see through.

JPG doesn't support alpha and I don't think flash add an alpha layer to loaded file ?

If the loaded image has an alpha layer I could set the alpha to 0 for each pixel but I have no idea on how to proceed ...

Does someone know how ? or simply if it's possible ? or any idea on how to achieve this ?

Thx a lot

+1  A: 

What you need to do is to load the data into a BitmapData object. You do this like so:

var bitmapData:BitmapData = new BitmapData(image._width, image._height, true);
bitmapData.draw(image);

Then you need to use the threshold method to swap out the green for another color. It's a very powerful method, though a bit tricky to use.

bitmapData = bitmapData.threshold(bitmapData, new Rectangle(0, 0, image._width, image._height), new Point(0, 0), "==", 0x00CCCCCC, 0x000000FF, 0x00FF0000, false);

Finally you'll paint the BitmapData into a Bitmap object you want to display.

Branden Hall