I'm trying to replace a range of colours programmatically - I have sprites for a game that have parts of them in shades of magenta specifically so they can be recoloured to show their team colour (blue,red,etc).

I've been able to use BitmapData.threshold() to replace a single specific colour with another. What I need to be able to do though is set some sort of range of colours and appropriately shade them blue/green/red while keeping their relative light/dark shades.

Here's what I've used to do a single colour:
var thisBitmap:Bitmap = MySpriteBitmap; //source bitmap
var colouredBitmapData:BitmapData = new BitmapData(thisBitmap.bitmapData.width, thisBitmap.bitmapData.height, true, 0x00000000);
colouredBitmapData.threshold(thisBitmap.bitmapData, thisBitmap.bitmapData.rect, new Point(0,0), "==", 0xFFd6007f, 0xFFFF0000, 0xffffffff, true);
thisBitmap.bitmapData = colouredBitmapData;
Anyone able to point me the right way?