# Desaturating a movieclip using code

**URL:** <https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723>\
**Category:** flash\
**Created:** [May 30, 2008, 9:25am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723 "2008-05-30T09:25:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackcoma](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@blackcoma](https://forum.kirupa.com/u/blackcoma)\
**Post date:** [May 30, 2008, 9:25am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/1 "2008-05-30T09:25:23Z")

</div>

How can I desaturate a movieclip (to black&white) using AS3?

thanks. :rambo:

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [May 30, 2008, 10:42am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/2 "2008-05-30T10:42:34Z")

</div>

you turn the saturation on your screen down 😛

I highly doubt there is a way of doing photoshop stuff in flash

---

<div class="post-metadata">

**Author:** ![excogitator](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@excogitator](https://forum.kirupa.com/u/excogitator)\
**Post date:** [May 30, 2008, 11:00am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/3 "2008-05-30T11:00:50Z")

</div>

Maybe this might help

For black and white  
[http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs\_Parts&file=00001493.html](http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001493.html)

For Sepia  
[http://www.reflektions.com/miniml/template\_permalink.asp?id=379](http://www.reflektions.com/miniml/template_permalink.asp?id=379)

---

<div class="post-metadata">

**Author:** ![GhostDog](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@GhostDog](https://forum.kirupa.com/u/GhostDog)\
**Post date:** [May 30, 2008, 11:14am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/4 "2008-05-30T11:14:08Z")

</div>

[quote=blackcoma;2333504]How can I desaturate a movieclip (to black&white) using AS3?

thanks. :rambo:[/quote]

I use tweener for all that kind stuff. If you don’t know it check it out:

[http://code.google.com/p/tweener/](http://code.google.com/p/tweener/)

…use special properties “colorshortcuts” and the parameter \_saturation.

Its easy to implement and the documentation on the site is pretty good.

---

<div class="post-metadata">

**Author:** ![blackcoma](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@blackcoma](https://forum.kirupa.com/u/blackcoma)\
**Post date:** [May 30, 2008, 1:27pm UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/5 "2008-05-30T13:27:07Z")

</div>

Thanks GhostDog, looks good, I’ll probably try that

Randomagain, what kind of answer is that?  
You can control blur using code, so you can’t control saturation using code?

---

<div class="post-metadata">

**Author:** ![GhostDog](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@GhostDog](https://forum.kirupa.com/u/GhostDog)\
**Post date:** [May 31, 2008, 11:17am UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/6 "2008-05-31T11:17:57Z")

</div>

You probably found got it working by now, but this might help others.

First import the tweener and the special properties…

```auto
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;

```

…then initialize the special properties:

```auto
ColorShortcuts.init();

```

…and then you can use it like this:

```auto
Tweener.addTween(myMovieClip, {_saturation:0, time:2});

```

… or however you like.

---

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [May 31, 2008, 10:12pm UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/7 "2008-05-31T22:12:46Z")

</div>

Here you have it, with tweenFilterLite you can change saturation, contrast, and brightness dynamically using one line of code:

```auto

TweenFilterLite.to(my_mc, 1, {colorMatrixFilter:{contrast:2.1, saturation:1}});

```

[http://blog.greensock.com/tweenfilterliteas3/](http://blog.greensock.com/tweenfilterliteas3/)

---

<div class="post-metadata">

**Author:** ![ThePuzzleMaster](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/thepuzzlemaster/32/972_2.png) [@ThePuzzleMaster](https://forum.kirupa.com/u/ThePuzzleMaster)\
**Post date:** [June 15, 2008, 6:13pm UTC](https://forum.kirupa.com/t/desaturating-a-movieclip-using-code/261723/8 "2008-06-15T18:13:48Z")

</div>

What are these shenanigans?! There is a way to change saturation via as… You just need to use a colorMatrixFilter.

```auto

var matrix:Array= new Array();
    
matrix = matrix.concat([1, 1, 1, 0, 0]); // red
matrix = matrix.concat([1, 1, 1, 0, 0]); // green
matrix = matrix.concat([1, 1, 1, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha
	
cmFilter= new ColorMatrixFilter(matrix);
var filter=new Array();
filter.splice(0,1,cmFilter);
your_mc.filters=filter;

```
