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.8. Restoring a Movie Clip’s Original Color

Problem

You want to restore the original symbol’s color values to a movie clip.

Solution

Reset the transformation object using the setTransform( ) method of the Color object that targets the movie clip.

Discussion

No matter what changes you made to a movie clip’s color using setTransform( ) and setRGB( ) (or made at authoring time), you can restore the original color values using a reset transform object (one with 100 for the percentages and 0 for the offsets):

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

When this reset transform object is passed to the setTransform( ) method, the colors in the targeted movie clip are set to those of the Library symbol on which the clip is based:

// Create the Color object.
my_color = new Color(myMovieClip);

// Apply a unity transformation.
resetTransform = {ra: 100, rb: 0, ga: 100, gb: 0, ba: 100, bb: 0, aa: 100, ab: 0};
my_color.setTransform(resetTransform);

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