You want to control the color of a movie clip dynamically (at runtime, rather than during authoring).
Create a Color object that targets the desired movie clip, and then use the Color.setRGB( ) method.
You can't change the color of a movie clip directly. Instead, you must first create a Color object that targets the movie clip of interest, as follows:
my_color = new Color(myMovieClip);
You can alternatively specify the movie clip name as a string:
my_color = new Color("myMovieClip");
|
A Color object can target a movie clip on any timeline using an absolute or relative reference, such as:
my_color = new Color(_root.myMovieClip); my_color = new Color(_parent.myMovieClip);
Once you have created a Color object, you can use it to control the color of the targeted movie clip instance.
The Color.setRGB( ) method applies a single color value to the movie clip targeted by the Color object (as specified when the Color object was created), filling the entire movie clip shape with a single color. The color value can be of any valid ActionScript numeric format.
The following examples both apply a solid blue color to the targeted movie clip:
my_color.setRGB(0x0000FF); // Hexadecimal my_color.setRGB(255); // Decimal
The following examples both apply a solid lime green color to the targeted movie clip:
my_color.setRGB(0xA9FC9C); // Hexadecimal my_color.setRGB(11140252 ); // Decimal
Recipe 5.2