How to Control All Sounds Globally |
| globalSound = new Sound(); |
If the above example is placed on frame one of the _root timeline, anything you do to that sound object will happen to all others, regardless of how they are defined, where they are defined or to which movie clip they are associated. There is nothing magical about the name of the sound object. You can call it what you like. The key is that it is not associated with any specific movie clip, therefore it affects the _root timeline and any sound object added or nested into the _root timeline.
Creating a global sound object will also affect non-sound object audio. For example, you could control the volume of an imported video using the global sound object. Understanding this would allow you to raise, lower or mute the volume at specific locations in the video - effectively providing a way to edit the audio. Controlling volume is described in the next section.
| firstSound = new Sound(firstSoundMc); firstSound.attachSound("firstSound01"); // secondSound = new Sound(); secondSound.attachSound("secondSound01"); |
As in the above example, one sound object was defined on the _root timeline as being assigned as a child of the movie clip "firstSoundMc". The other, secondSound, was not assigned to any movie clip. Note how these two sounds are stopped in the following example:
For firstSound:
| on(press) { firstSound.stop(); } |
For secondSound:
| on(press) { secondSound.stop(); } |
They are stopped exactly in the same manner. However, because "firstSound" was assigned to be the child of the movie clip "firstSoundMc", the stop call to the "firstSound" sound object only stops sounds associated with the movie clip "firstSoundMc". All other sounds continue.
On the other hand, by pressing the stop button for "secondSound", which was not assigned to a movie clip, it will stop all sounds, including sounds assigned to a specific movie clip. This can be convenient if you want to stop all sounds or control the volume or panning for all sounds.
| » Level Intermediate |
|
Added: 2004-10-12 Rating: 8 Votes: 31 |
| » Author |
| Kenny Bellew is a technical writer and freelance flash programmer who specializes in Flash audio. He lives in Minneapolis, MN. |
| » Download |
| Download the files used in this tutorial. |
| Download (12927 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!