1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

MovieClip Saturation Class - ActionScript 2

This ActionScript 2.0 Class enables you to easily adjust the colour saturation of any Flash MovieClip during runtime. It requires Flash Player version 8 or above, and uses the ColourTransformationMatrix and some clever jiggery-pokery to adjust the RGBA channels of your MovieClips. In short, it’s sweet - and fills a gap in the built-in flash filter classes.

Have a look at this flash movie (below) to see the end result, all generated from the same MovieClip.

Now, before I go much further, I should point out that the functions that make this possible are down to senocular, whose equally awesome code this is based on. All I really did was figure out a way to turn it into an ActionScript 2.0 Class. - Technically it doesn’t even need to be in a class - but it just makes things easier.

Using this Class

Firstly, you’re going to want to download the source files. It’s as basic as it comes - using it ‘out-the-box’ requires that you take the ‘mmt’ folder, and paste it into the same directory as your .fla file. And then, by typing;

mmt.SaturationManager.setSaturation(your_movieclip, the_saturation);

You’ll be able to modify the colour saturation of the MovieClip. “your_movieclip” is obviously a reference to the MovieClip, and “the_saturation” is a value from 0 (No Colour) to 100 (Normal Colour). You can apply values beyond 0 and 100, and oversaturate the colours. In our example (above) the [1st on the left, bottom row] MovieClip is oversaturated, at 150%.

Downloads

Download the source files, containing example .fla and .as files [ZIP, 488KB]
Download only the .as file [ActionScript File, 1KB]

9 Comments »

  1. Thanks very usefull.

    Comment by Steven Archer — 6 October 2007 #

  2. Thanks mate.
    Came in handy :)

    Comment by Jadon — 27 December 2007 #

  3. Thanks, I was looking for some saturation formulas to program one myself, but since I’m on a tight schedule for the moment, this class comes in more than handy!

    Great job!

    Comment by Wout — 8 February 2008 #

  4. You legend - this worked perfectly. I Googled a lot on the matter and this is by far the best example. Thanks again and keep up the good work!

    Comment by Tim — 25 February 2008 #

  5. Is it possible to use your class when I first load an external jpg file into a movieclip and then try to change the saturation?

    Comment by Martin Bartels — 28 February 2008 #

  6. @Martin - it should be fine, you can apply the saturation changes at any point in your timeline / code.

    Comment by James — 29 February 2008 #

  7. I have a jpg into a movie, with 26602 pixels wide and 100 pixels tall (719Kb in disk).
    And it doesn’t work.
    Do you know something about size limitations (file size and/or image size)?
    Thank you.

    PS.: I’ve tested with normal images and it worked just fine.

    Comment by Sniffer — 1 March 2008 #

  8. Duh! I’ve found: there is a 2880 pixels limit.
    Thanks anyway.

    Comment by Sniffer — 1 March 2008 #

  9. a million thank yous for such a great design and
    such ease of implementation.
    more more!

    Comment by Up to my ears in Flash — 6 May 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Note: This post is over 8 months old. You may want to check later in this blog to see if there is new information relevant to your comment.