Creating interactivity and visual effects 573
8. Repeat step 7 for the other buttons (red_btn, green_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):
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
var trans:Transform = new Transform(car_mc);
trans.colorTransform = colorTrans;
blue_btn.onRelease = function() {
colorTrans.rgb = 0x333399; // blue
trans.colorTransform = colorTrans;
};
red_btn.onRelease = function() {
colorTrans.rgb = 0xFF0000; // red
trans.colorTransform = colorTrans;
};
green_btn.onRelease = function() {
colorTrans.rgb = 0x006600; // green
trans.colorTransform = colorTrans;
};
black_btn.onRelease = function() {
colorTrans.rgb = 0x000000; // black
trans.colorTransform = colorTrans;
};
9.
Select Control > Test Movie to change the color of the movie clip.
For more information about the methods of the ColorTransform class, see ColorTransform
(flash.geom.ColorTransform) in the ActionScript 2.0 Language Reference.
Creating sound controls
You use the built-in Sound class to control sounds in a SWF file. To use the methods of the
Sound class, you must first create a Sound object. Then you can use the
attachSound()
method to insert a sound from the library into a SWF file while the SWF file is running.
The Sound class’s
setVolume() method controls the volume, and the setPan() method
adjusts the left and right balance of a sound.
The following procedures show how to create sound controls.
To attach a sound to a timeline:
1. Select File > Import to import a sound.
2. Select the sound in the library, right-click (Windows) or Control-click (Macintosh), and
select Linkage.