May 28, 2001 - Rewinding a SWF | WebReference

May 28, 2001 - Rewinding a SWF

Yehuda Shiran May 28, 2001
Rewinding a SWF
Tips: May 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

In some of your applications you may need to use Flash Audio and JavaScript directly, without any prepackaged APIs such as FlashSound JavaScript API. You will enjoy more features, methods, and properties, but you'll have to take care of all the tiny details that are taken for granted when using FlashSound API.

One of the "tiny" details is embedding the sound object. The JavaScript file included in this tip, flashsoundcheck.js, does exactly this, and other stuff. It also checks for Flash plug-ins, and minimum player version.

The link below demonstrates the Rewind() Flash method. The syntax is just Rewind(). It positions the playhead at the beginning of the track, ready to play the sound from the first frame. When you have several sound tracks on the same SWF, the playhead will jump to the first track when you call Rewind(). Try the animal sounds below. When you click the Rewind() link, the playhead goes to the first frame of the track. When you click the Play link, the playhead will start moving, sounding off "dog barking". Play with the animal sounds. Rewind the track and then play() it.

| Dog Barking | Frog Ribbet | Horse Whinny | Cat meow | Rewind | Play |

Here is the source code:
<SCRIPT LANGUAGE="JavaScript" SRC="flashsoundcheck.js"></SCRIPT>
| <A href="javascript://" onclick="sonified_flash(10); return false">Dog Barking</a> |
<A href="javascript://" onclick="sonified_flash(30); return false">Frog Ribbet</a> |
<A href="javascript://" onclick="sonified_flash(60); return false">Horse Whinny</a> |
<A href="javascript://" onclick="sonified_flash(80); return false">Cat meow</a> |
<A href="javascript://" onclick="mySwf.Rewind(); return false">Rewind</A> |
<A href="javascript://" onclick="mySwf.Play(); return false">Play</A> |
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("animalsounds.swf");
  var mySwf = window.document.sonify;
</SCRIPT>