Creating interactivity and visual effects
101
7
Repeat step 6 for the other buttons (red, green, and black) to change the color of the movie clip
to the corresponding color. Your code should now look like this:
myColor = new Color(_root.carColor)
_root.blue.onRelease = function(){
myColor.setRGB(0x0000ff)
}
_root.red.onRelease = function(){
myColor.setRGB(0xff0000)
}
_root.green.onRelease = function(){
myColor.setRGB(0x00ff00)
}
_root.black.onRelease = function(){
myColor.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
Chapter 12, “ActionScript Dictionary,” on page 205
.
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.
When the user releases the Play button, a song plays through the speaker.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...