1. Home
  2. Computing & Technology
  3. Animation

Using setTransform to Change Color and Opacity

By , About.com Guide

6 of 7

Let’s forget the select variable for a moment, and look at the setTransform: what does the actual work of changing the button color. Let’s look at the script, first, then break it down:
highlighting = new Color(_root.buttonything);
buttonhighlight = new Object();
buttonhighlight = { ra: '40', rb: '44', ga: '50', gb: '112', ba: '100', bb: '90', aa: '100', ab: '55'};
highlighting.setTransform(buttonhighlight);
Pretty confusing chunk of code, isn’t it? It might seem a bit less confusing if I tell you that it’s actually a great deal like setRGB. I’ve set a new Color object named highlighting, and then created a new generic object named buttonhighlight to hold the following values:

ra: Percentage (-100 to 100) of the red value in an RGB spectrum.
rb: Offset (-255 to 255) for red.
ga: Percentage of the green value.
gb: Offset of the green.
ba: Percentage of the blue value.
bb: Offset of the blue.
aa: Percentage for alpha/opacity.
ab: Offset for alpha.

Tweaking these values allows you to adjust how much the hue of the object is shifted in each color that forms the overall blend (red, green, blue) to adjust the tint, as well as the brightness and opacity. You’ll have play around with them a little to get the hang of it.

Once those values are defined, they can be assigned to the movie clip with the setTransform command – the last line of code above, by using the two objects created to link them back to the instance of the movie clip.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Using setTransform to Change Color and Opacity

©2009 About.com, a part of The New York Times Company.

All rights reserved.