For replacing specific RGB values, you can try BitmapData::threshold.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#threshold()

You should use "==" as the operation, the threshold parameter should be the
color you want to change, the color parameter should be the new color, use
0xFFFFFFFF as the mask and set copySource to true, so any pixel that doesn't
match the comparison is copied as is.

Depending on what you want to do, the paletteMap method could also be of use
(it'll let you remap each channel and it'll be fast if you want to change
many colors; it won't work for specific RGB values, though, but maybe you
can find some intermediate solution that will work for you, and it could be
faster).


Cheers
Juan Pablo Califano


2009/1/13, peter ginsberg <malphig...@gmail.com>:
>
> Is there any way to do color swaps in AS3?
>
> What I'm looking to do is:
> Take a given DisplayObject (MovieClip or Sprite to be specific), look for
> particular colors (specific RGB values) and replace those colors with other
> specific RGB values, all without touching any other colors.
>
> Sort of like something you would do with an indexed color image.
>
> Currently I'm doing this in a far more tedious way (making each colored
> area
> I want to swap into a named movie clip and iterating through all the
> children then tossing a color transform on the clips).
>
> I thought maybe I could work soemthing out with a ColorMatrixFilter, but it
> doesn't seem like it will work.   Maybe dealing with the whole image as bit
> map data?  Although would that be a performance concern?
>
> Thanks in advance for any advice!
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to