I have a DisplayObject (let it be a Sprite).
What I need is to make content under it black-and-white (only within i开发者_Python百科ts borders). Any suggestions?
Thanks.
You could grab the stage under it, clipped to the rect of the sprite you want to use, desaturize the bitmap (with a colormatrixfilter or the tween code from @chris' answer) and addChildAt(bitmap, 0)
it inside the sprite as a background.
Then hope that nothing underneath changes because then you'd have to do it all again to reflect those changes into the b/w background.
I have not tried that myself but it might work.
Download TweenMax (best tweening platform for Flash in my personal opinion).
http://www.greensock.com/tweenmax/
Then all you need to do is import it and add the following:
import com.greensock.*;
import com.greensock.easing.*;
TweenMax.to(mc, 1, {colorMatrixFilter:{colorize:0x000000, amount:0.5, saturation:0}});
That will change the mc to black and white over the course of 1 second, you could of course change it to 0 for instant black and white.
精彩评论