spacer
Yehuda Shiran April 24, 2001
Accessing Non-API Properties
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?

FlashSound gives a unique ID to each sound instance. This property is called playerID. The playerID is in the form of "FlashSound_swf" plus an index starting at 0. For example, the first SWF embedded on the page with embedSWF() has playerID of "FlashSound_swf0", and the second would be "FlashSound_swf1".

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. Download.
  • 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.

You can use the playerID to access non-API properties of the element. Some properties that are not supported by FlashSound API are: movie, play, quality, wmode, width, and height. To access the width property, you write:

window.document[mySoundObj1.playerID].width)

Mouse over the following three links. Each link will alert you with the object's width:

Play a Scale    Start a Looping Sound    Stop a Looping Sound

Here is the source code:

<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
<SCRIPT>
  var mySoundObj1 = new FlashSound();
  var mySoundObj2 = new FlashSound();
</SCRIPT>
</HEAD>
<BODY>
<A HREF="javascript://" onmouseover="mySoundObj1.TGotoAndPlay('/scale-event','start');
alert('width is ' + window.document[mySoundObj1.playerID].width);">Play a Scale</A>
<A HREF="javascript://" onmouseover="mySoundObj2.TGotoAndPlay('/loop-event','start');
alert('width is ' + window.document[mySoundObj2.playerID].width);">Start a Looping Sound</A>
<A HREF="javascript://" onmouseover="mySoundObj2.TGotoAndPlay('/loop-event','stop');
alert('width is ' + window.document[mySoundObj2.playerID].width);">Stop a Looping Sound</A> 
<SCRIPT>
  mySoundObj1.embedSWF("scale.swf");
  mySoundObj2.embedSWF("loop.swf");
</SCRIPT>
</BODY>
</HTML>

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

Download flashsound.js

Download loop.swf

Download scale.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