1. Home
  2. Computing & Technology
  3. Animation

Using setTransform to Change Color and Opacity

By , About.com Guide

7 of 7

The last thing to do is adjust the setTransform and do a little rearranging so that the tint on the button flips back and forth as it’s pressed. For that we’re going to use the value of select and an if statement to determine which values of the setTransform are used to affect (or not affect) the clip. You should be able to work out how it works from the full script:
onClipEvent (load) {
var select=false;
}
on (release) {
select=!select;
highlighting = new Color(_root.buttonything);
buttonhighlight = new Object();
if (select==true){
buttonhighlight = { ra: '40', rb: '44', ga: '50', gb: '112', ba: '100', bb: '90', aa:
'100', ab: '55'};
highlighting.setTransform(buttonhighlight);
}
if (select==false){
buttonhighlight = { ra: '100', rb: '0', ga: '100', gb: '0', ba: '100', bb: '0', aa:
'100', ab: '255'};
highlighting.setTransform(buttonhighlight);
}
}

And there you have it. This is a simple way to use setTransform, but you can apply it in more advanced ways.

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.