Color Object and setTransform in Macromedia Flash
Color.setTransform() was introduced in Flash 5. It gives you precise control over the RGB values of a movieclip. Interesting visual effects such as turning a positive image into negative can be achieved using ActionScript. This sample includes a lightweight slider component.
User comments:
Hi, I think it works great on your site, but I download the fla file and my Flash MX 2004 says it has errors . Do you think its possible to convert the code to AS2?
It is fixed for now. But still using legacy code.
I had trouble trying to see the slidder work there is a syntax error. Would you tell me what is the problem?
We have fixed this error. Lesson: NEVER use a reserved word as a variable :). Flash 5 had no complaint but the more strict MX 2004 rightly screams when you have a variable named default.
This is a great demonstration of setTransform! Thanks for creating it! I have been trying to figure out exactly what "percentage" and "offset" MEAN, in a logical or mathematical explanation. I still haven't figured it out, but this helps a great deal. If you know what they mean, please let me know. - Seth
According to Colin Moock [ActionScript for Flash MX, The Definitive Guide, O'Reilly, 2003]:
r = r_original * (ra/100) + rb
g = g_original * (ga/100) + gb
b = b_original * (ba/100) + bb
where
ra, ga, ba { -100 .. +100 } (percentage)
rb, gb, bb { -255 .. +255 } (offset)
For instance to create a negative image:
ra = ga = ba = -100 rb = gb = bb = +255 r = r_original * (-100/100) + 255 = 255 - r_original; g = g_original * (-100/100) + 255 = 255 - g_original; b = b_original * (-100/100) + 255 = 255 - b_original;
Sorry, I do not have time to answer questions related to these scripts.
You can always get help on the Kirupa Flash Forums. Thank you for visiting.

