April 15, 2001 - Parallel Looping Sounds | WebReference

April 15, 2001 - Parallel Looping Sounds

Yehuda Shiran April 15, 2001
Parallel Looping Sounds
Tips: April 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Flash has four different sync options: event, start, stop, and stream. You assign the type of the sound during editing. In this tip we discuss the event sync.

With event sync, Flash can play multiple copies of the same sound at the same time. It replicates itself while it is currently playing. This replication is often referred to as a new "instance" of the same sound. If you re-trigger an event sound while it is playing, it does not stop, rewind, and restart the sound. Instead, you get layering of multiple instances of the same sound playing at the same time.

As a reminder, in order to sonify your page, follow this recipe:

flashsound.js in the HEAD section.
  • Create a flashsound object in the
  • HEAD section.
  • Embed your SWF file in the
  • BODY section.
  • Create an anchor tag and set the
  • onmouseover event handler to the TGotoAndPlay() method.

    Using the event sync may be problematic when you use it for looping sounds. You can assign a sound to loop via the Flash editor. When you play several looping sounds in parallel, you get an amplifying effect that may not be pleasant to the your ears. Mouse over the left link below a few times. Hear the effect:

    Start Looping Sound Stop Looping Sound

    Here is the source code:

      <SCRIPT SRC="flashsound.js"></SCRIPT>
        var mySoundObj = new FlashSound();
    <A HREF="javascript://" onmouseover="mySoundObj.TGotoAndPlay('/loop-event','start')">Start Looping Sound</A> 
    <A HREF="javascript://" onmouseover="mySoundObj.TGotoAndPlay('/loop-event','stop')">Stop Looping Sound</A> 

    Here are links you can use to download flashsound.js and loop.swf:

    Download flashsound.js

    Download loop.swf