8.
Repeat step 7 for the other buttons (
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
method to insert a sound from the library into a SWF file while the SWF file is running.
The Sound class's
setVolume()
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.
,
red_btn
green_btn
method controls the volume, and the
Creating interactivity and visual effects
, and
) to change the
black_btn
attachSound()
method
setPan()
573
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?