spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column82


Embedding Sound with Flash, Part II: Playing Variations

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

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

http://www.internet.com

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


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: April 23, 2001
Revised: April 23, 2001

URL: http://www.webreference.com/js/column82/11.html