User Guide

188 Chapter 6: Creating Interaction with ActionScript
5.
To create a Color object that targets the car_mc movie clip, add the following code to the
Actions panel:
var myColor_color:Color = new Color(car_mc);
6.
To make the red button change the color of the carColor movie clip to red, add the following
code to the Actions panel:
red_btn.onRelease = function() {
car_color.setRGB(0xFF0000);
};
The hexadecimal value 0xFF0000 is red.
7.
Repeat step 6 for the other buttons (green_btn, blue_btn, and black_btn) to change the color
of the movie clip to the corresponding color. Your code should now look like the following
example (new code is in bold):
var car_color:Color = new Color(car_mc);
red_btn.onRelease = function() {
car_color.setRGB(0xFF0000);
};
green_btn.onRelease = function() {
car_color.setRGB(0x00FF00);
};
blue_btn.onRelease = function() {
car_color.setRGB(0x0000FF);
};
black_btn.onRelease = function() {
car_color.setRGB(0x000000);
};
8.
Select Control > Test Movie to change the color of the movie clip.
For more information about the methods of the Color class, see the Color class entry in
ActionScript Dictionary Help.