A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Audio

Categories How to Use Flash MX Sound Objects
Author: Kenny Bellew | Website: http://www.cowfly.com |

 
Page 7
«prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... next»

How to Control Independent Sound Objects Simultaneously

As stated earlier, wherever you attach the sound object, it becomes a child of that movie clip. Think of the movie clip as a container for the sound. Any call to a method of a sound object, such as setVolume, will affect all sound objects that are the child of that particular timeline. Therefore, to affect multiple sound objects independently, each sound object must be associated with its own unique movie clip. This can be an empty movie clip or one that is being used for something else. The result will be to group your sound objects by movie clip. It is very important to understand that this grouping is achieved in the way the sound object is defined - not by where it is defined.

This is a common trouble spot when first starting to learn to use sound objects. For example, you may have figured out how to fade the volume for a sound object, but you find that it is also fading the volume for all other sound objects, too. The reason for this can usually be found in how the sound object was defined.

The following is an example of how to assign a sound object as the child of a particular movie clip when the sound object is initially defined:

Define the sound object

firstSound = new Sound(firstSoundMc);
firstSound.attachSound("firstSound01");

In the above example, "firstSoundMc" is the instance name of a movie clip. Also notice that there are no quotes around the movie clip instance name in the ActionScript.

Create an empty movie clip and drag it out onto the _root stage (or even off stage). Give the movie clip the instance name of "firstSoundMc" (of course, you can name the move clip whatever you want. For this example, it will be "firstSoundMc").

It is not necessary for the "firstSoundMc" movie clip to contain the ActionScript that starts the sound object. The "firstSoundMc" movie clip can remain empty. The sound object "firstSound" then becomes a child of "firstSoundMc". The only purpose of firstSoundMc is to serve as a container or association for the sound object.

It is not necessary to create an associated movie clip for sound objects that only need to be started. It is needed when advanced methods such as setVolume and setPan are required for multiple independent sound objects, or when the need arises to stop one sound object while others continue.

Once this is done, the methods of "firstSound" can be manipulated independent of the other sound objects. Ways by which the sound object's methods are called do not change. In other words, once you define the sound object as being attached to a particular movie clip, you never again need to reference that movie clip to control the sound object. Since, in our example, the sound object was defined on the _root level, calls to methods of the sound object would still only need to reference the _root path.

For example, if you wanted to pan firstSound completely into the left speaker channel, the following would be used:

_root.firstSound.setPan(-100);

Note the differences in the ways the following sound objects are defined:

//
firstSound = new Sound(firstSoundMc);
firstSound.attachSound("firstSound01");
//
secondSound = new Sound();
secondSound.attachSound("secondSound01");
//

Then, hypothetically, on a button in the movie some place

on (press) {
_root.firstSound.setPan(-100)
}

And on a different button...

on (press) {
_root.secondSound.setPan(-100)
}

Fig. 05: Example of effects of using and not using an associated movie clip with the sound object

In the above example, if you panned firstSound, only the sounds associated with the movie clip "firstSoundMc" would pan to the left. If you panned secondSound with the above configuration, all sounds, regardless of where they were defined or to which movie clip they were assigned, would pan to the left.

It is natural to think that firstSound, which is associated to firstSoundMc by definition (firstSound = new Sound(firstSoundMc)) would be protected from changes to secondSound. However, it is not. The benefit of this is that you can make a global sound control that will will override individual settings.

In Fig. 05, two pan sliders are configured as defined above. Experiment with the sounds. Start both sounds with the green buttons. Next, pan "firstSound" left and right and see how it only effects firstSound. Then, and with both sounds playing, pan secondSound. Notice that it affects both sounds. Be sure to experiment with secondSound after firstSound.

There is another way to associate sounds with specific movie clip instances. Define the sound object as before, except instead of indicating the name of a movie clip instance, use the keyword word "this" as follows:

 thirdSound = new Sound(this);
 thirdSound.attachSound("thirdSound01")

Fig. 05b: Example of using the keyword "this" to associate a sound object with the movie clips in which its being defined

If the sound object is defined using the keyword "this", calls to the sound objects, such as setVolume() and stop(), will only affect the timeline (the movie clip) where the sound object is defined. Experiment with the Flash examples in Fig05b. Notice that the sound object, thirdSound, which is defined with the keyword "this", reacts identically to the sound object "firstSound", which was associated to a specific movie clip when it was defined on the _root timeline.

Using the keyword "this" has advantages and disadvantages. One advantage is that, if the SWF file containing the sound object will be loaded into another movie using loadMovie, there is no risk of losing its association with the movie clip it was associated with when it was originally defined. This allows you to export sound objects as SWF's, import them into a different movie clip and still have control of the sound object. How to do this will be discussed in the section: How to Preload Sound Objects that use the attachSound Method.

«prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... next»

» Level Intermediate

Added: : 2004-10-12
Rating: 8.48 Votes: 31
Hits: 1290
» 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)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs