Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

FlashSound API: The Sound of Invisible Flash  : Page 8

Learn to use Flash to add interactive sound to your Web pages.


advertisement
Sonify Your Web Site: Add Backing Music
You can use the FlashSound API to add backing music to your Web site as well as interactive sound. Backing music is a great way to add ambiance and character to a site. Flash has two kinds of sound playback, stream and download. There are pros and cons to using either downloaded or streamed sounds. Be sure to consider these before deciding on a method of delivery.

  • A stream sound plays as it loads. Therefore, a user does not have to wait long to hear sound. However, the disadvantage is that bit rates of 32kbps or less, (required for steady streaming on a 56kbps modem), often produce low quality music or sound. In addition, users will experience breaks in the sound if their data transfer rate cannot keep up with the stream.
  • Downloaded sounds do not begin to play until they are fully loaded. Therefore, you should use this method only with sounds that fit into small files so that users don't have to wait too long for the sound to start. The advantage of downloaded sounds is that they don't break up over slow connections and (because there's no bandwidth limitation during playback) can be of higher quality. You can achieve a reasonable balance between sound quality and download time with higher bit rates (32kpbs or more) if your sound has a short duration (less than 5 seconds).
Autostart Download Sounds
To create an Autostart sound, change the ActionScript
Figure 16.
in frame 1 of your sound's movie clip to TGotoAndPlay("start"). This method tells Flash to jump to the start frame. Flash will wait until the sound is fully loaded, then automatically begin playingthe sound. This technique does not require JavaScript to play the sound (see Figures 15 and 16).

Play a Download Sound After Page Load
Sometimes you need to play backing music after the page layout is in place. In this case, do not use the Autostart approach because with that approach your sound may start playing before the layout is rendered. Instead, use the window.onload event to play backing music. With this technique, the browser waits until your SWF file and all the graphics and HTML on the page are fully loaded before playing the music. The following code is similar to the onMouseover code on the previous page, but in this case, you use the onLoad event handler in the body tag to trigger the TGotoAndPlay( ) method.

<body onLoad = "mysound.TGotoAndPlay('/backingmusic','start' )">

Stop Background Music
You can stop an onLoad or Autostart sound with the TGotoAndPlay("targetpath","stop") method. Specify the target path and stop frame of the movie clip containing the sound you want to stop. For example:

<a href="javascript://" onClick= "mysound.TGotoAndPlay('/backingmusic','stop')"> Stop Background Music </a>

Looped Backing Music
To loop a sound in Flash, select your sound on its timeline and enter a value between 2 and 999 in the Sound Panel loop entry box. Looping a sound does not change the size of your SWF file (see Figure 17).



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date