Đang chuẩn bị liên kết để tải về tài liệu:
Học Actionscript 3.0 - p 33
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Internal and External Sounds Once you’ve provided a linkage class name, you can create an instance of the sound the same way you instantiate a movie clip: var snd:Sound = new ClaireElmo(); N OT E Thereafter, you can manage the instance of this sound by referring to the variable snd. This creation of a Sound class instance and the use of one method to load a sound file are the only basic differences between using internal and external sounds. All play, pause, stop, and transform operations are identical, regardless of the sound source. If you prefer to use internal sounds, the using_internal_sound.fla source file demonstrates the playing and. | Internal and External Sounds Once you ve provided a linkage class name you can create an instance of the sound the same way you instantiate a movie clip var snd Sound new ClaireElmo Thereafter you can manage the instance of this sound by referring to the variable snd. This creation of a Sound class instance and the use of one method to load a sound file are the only basic differences between using internal and external sounds. All play pause stop and transform operations are identical regardless of the sound source. If you prefer to use internal sounds the using_internal_sound.fla source file demonstrates the playing and stopping of a short imported sound using the basic syntax explained in the Playing Stopping and Pausing Sounds section later in this chapter. However we recommend using external sounds for most uses. NOTE Another difference between working with internal and external sounds is that you can buffer a loaded sound to improve playback experience. Buffering a sound means that your playback won t begin until a specified amount of sound data has loaded. This allows the background loading of the rest of the sound to stay ahead of your playback and is discussed in the Buffering Sounds section later in this chapter. Loading External Sounds Using internal sounds creating an instance of the Sound class and populating it with audio occur in one step. To load a sound from an external MP3 we need to use the load method of the Sound class so we must first explicitly create an instance of the class. This is shown in line 1 of the following code found in the loading_external_sound.fla source file. 1 var snd Sound new Sound 2 3 var req URLRequest new URLRequest song.mp3 4 snd.load req As discussed in prior chapters you also need to create an instance of the URLRequest class line 3 any time you load something. Although it has additional purposes for advanced URL processing the URLRequest class is also used to standardize the loading process. This allows you to load .