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
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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