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( ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.