A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11249 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: kyo
» Title: building estructure
» Description: explosion of building estructure made by swift3D
» More by kyo


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Webdancer's Web Site
» Comments: Webdancer's, an artistic adventure in 3d graphicsbr>


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

» Let Photos Show Your Happy Family this Christmas and Upload YouTube
» PowerPoint show to DVD slide show--- PPS to DVD
» How to burn FLV to DVD for Mac
» How to Create Christmas Flash Greeting Ecard with photos and music
» Getting Started In Flash
» How to convert FLV video to MP3 audio for Mac OS
» Join flv videos together with just a few clicks
» How to convert flv file to avi for mac os x
» How to Create Christmas Flash Greeting eCard without programming skills
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Senior Web Designer
Aquent
US-GA-Atlanta

Justtechjobs.com Post A Job | Post A Resume


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

Search Tutorials


Tutorials Tutorials » Audio

Categories Flash MX Sound Object Tutorial
Author: Kenny Bellew

 
Page 5
«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. 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's 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:

  1. 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.
  2. Create an empty movie clip and drag it out onto the _root 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.

In Fig. 05 (shown to the left), 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. The other advantage is that it is easier to configure (fewer steps). The disadvantage is that the path to the sound object must be used when calling it into action. If there are a lot of sound objects scattered about in numerous movie clips, it can become a tangled web.

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

» Level Intermediate

Added: : 2002-08-13
Rating: 9.13 Votes: 653
Hits: 3000
» Author
Kenny Bellew is a technical writer in Minneapolis, MN. He's currently interested in becoming involved in other writing-related Flash projects.
» Download
Download the files used in this tutorial.
Download (6170 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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES