spacer
Yehuda Shiran April 19, 2001
Looping an SWF
Tips: April 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The FlashSound JavaScript API supports several instance properties. The loop property tells the Flash player to re-trigger the track when the playhead reaches the end of the track. The SWF file should not include a stop label at the end of the track because it inhibits its looping, even if you specify loop=true before you embed the SWF file. As a reminder, in order to sonify your page, follow this recipe:
  • Make sure you have the Flash player. 96% of the surfing population already has it. Download.
  • Include 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 onclick event handler to the TGotoAndPlay() method.

In this tip we demonstrate an SWF file that by default start playing when embedded in a page. The following two links point to two pages with similar code:

loop=true   loop=false

Here is the code for the left link:

<HTML>
<HEAD>
  <SCRIPT SRC="flashsound.js"></SCRIPT>
  <SCRIPT>
    var mySoundObj = new FlashSound();
  </SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
  mySoundObj.loop = true;
  mySoundObj.embedSWF("theme.swf");
</SCRIPT>
</BODY>
</HTML>

Notice the loop=true assignment. You assign instance properties before you embed the SWF file by embedSWF(). The right link above is the same as the left link, except that the loop parameter is false. Notice that the sound loops forever in the left link, but stops after one round in the right link.

Also important to remember is the fact that not every sound track can be made to loop. In fact, most SWF files are not suitable, because they contain a stop label at the last frame.

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

Download flashsound.js

Download theme.swf


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business