Accessing non-API Properties
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".
You can use the playerID to access non-API properties of the embedded element. Some properties that are not supported by FlashSound API are: movie, play, quality, wmode, width, and height. To access the width property, for example, you write:
window.document[mySoundObj1.playerID].width
Mouse over the following three links. The left link will alert you with the object's playerID. The middle link will alert you with its width. The right link will alert you with its object's playerID, which is common to the middle one:
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('SWF Object ID is ' + mySoundObj1.playerID);">
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('SWF Object ID is ' + mySoundObj2.playerID);">
Stop a Looping Sound</A>
<SCRIPT>
mySoundObj1.embedSWF("scale.swf");
mySoundObj2.embedSWF("loop.swf");
</SCRIPT>
</BODY>
</HTML>
           
Next: A Final Word
|