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);
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.