O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.7. Transforming a Movie Clip’s Current Color

Problem

You want to modify a movie clip’s color relative to the current color transformation, instead of relative to the author-time color values.

Solution

Use the getTransform( ) and setTransform( ) methods of the Color object that targets the movie clip.

Discussion

The Color.getTransform( ) method returns the transform object last applied to the targeted movie clip. For example, if you had previously applied a transform object that set the movie clip’s alpha percentage to 42, getTransform( ) would return an object with the following values:

{ra: 100, rb: 0, ga: 100, gb: 0, ba: 100, bb: 0, aa: 42, ab: 0}

The transform object reflects changes made to a movie clip’s color either at authoring time or at runtime. If you modify the color values using the Property inspector at authoring time, those values are indicated in the movie clip’s transform object. You can make changes to a movie clip’s color at runtime by using the setTransform( ) or setRGB( ) methods of its Color object, and you can adjust the movie clip’s _alpha property separately. All runtime changes—not just the changes made using setTransform( )—are reflected in the transform object. If you have not applied any color changes at runtime or authoring time then getTransform( ) returns the following value (a neutral transform object):

{ra: 100, rb: 0, ga: 100, gb: 0, ba: 100, bb: 0, aa: 100, ab: 0}

You can modify the properties of the transform object returned by getTransform( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required