Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Microphone and Audio > Working with Sounds

Working with Sounds

Now that your sound files are ready, let’s see how we can use them. All sound-related classes belong to the flash.media package and will be introduced throughout this chapter.

Loading Sounds

The Sound class gets access to the audio information to load the sound file. It is a subclass of the EventDispatcher class.

As discussed before, your sound can be embedded, it can be loaded as an external file from your application assets directory, or it can be downloaded from a remote server. For the latter, advise your audience to use WiFi over 3G for a better experience.

If you try to play a sound that is not loaded, you will get a runtime error. Create a listener to be notified when the loading is complete, and then play your file:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint