User Guide

Creating interactivity and visual effects 187
display_txt.text = "Right";
} else if (Key.isDown(Key.UP)) {
this._y = Math.max(this._y-distance, 0);
display_txt.text = "Up";
} else if (Key.isDown(Key.DOWN)) {
this._y = Math.min(this._y+distance, 400-this._height);
display_txt.text = "Down";
}
};
8.
Select Control > Test Movie to test the file.
For more information about the methods of the Color class, see the Color class entry in
ActionScript Dictionary Help. For more information about the methods of the Key class, see the
Key class entry in ActionScript Dictionary Help.
Setting color values
You can use the methods of the built-in Color class to adjust the color of a movie clip. The
setRGB() method assigns hexadecimal red, green, blue (RGB) values to the movie clip. The
following example uses
setRGB() to change an object’s color based on user input.
A button action creates a Color object and changes the color of the car based on user input.
To set the color value of a movie clip:
1.
Select a movie clip on the Stage.
2.
In the Property inspector, enter carColor as the instance name.
3.
Create a button named colorChip, place four instances of the button on the Stage, and name
them red_btn, green_btn, blue_btn, and black_btn.
4.
Select Frame 1 in the main Timeline, and select Window > Development Panels > Actions.