April 24, 2001 - Accessing Non-API Properties | WebReference

April 24, 2001 - Accessing Non-API Properties

Yehuda Shiran April 24, 2001
Accessing Non-API Properties
Tips: April 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

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:

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