spacer

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

home / experts / javascript / column84


Embedding Sound with Flash, Part IV: Native JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Using Flash Methods

Let's demonstrate a few methods of the Flash JavaScript object. The following function checks for the minimum player version and then jumps to the required frame to start the sound. The sonified_flash() function accepts one parameter (the frame number), checks for the minimum player version number, creates a SWF object, ensures that the SWF is 100% loaded, and then jumps to the given frame:

function sonified_flash(myFrame) {
  if(!Flash_checkForMinPlayer()) {return;}
  mySwf = window.document.sonify;
  if (mySwf.PercentLoaded()<100) return
  mySwf.GotoFrame(myFrame);
  mySwf.GotoFrame(0);
}

We showed here two methods: PercentLoaded() and GotoFrame(). The following links demonstrate the embedding of animalsounds.swf in this page. Try these links and refresh your last visit to the farm:

| Dog Barking | Frog Ribbet | Horse Whinny | Cat meow |

You need to include the file flashsoundcheck.js in the HEAD section of your page:

<SCRIPT LANGUAGE="JavaScript" SRC="flashsoundcheck.js">
</SCRIPT>

This file includes the function Flash_embedSWF() which embeds SWFs, and does all the necessary checking of the browser/plug-in combinations. The animal sound links above are implemented by the following code:

| <A href="javascript://" onclick="sonified_flash(10);
  return false">Dog Barking</a> |
<A href="javascript://" onclick="sonified_flash(30);
  return false">Frog Ribbet</a> |
<A href="javascript://" onclick="sonified_flash(60);
  return false">Horse Whinny</a> |
<A href="javascript://" onclick="sonified_flash(80);
  return false">Cat meow</a> |
<SCRIPT LANGUAGE="JavaScript">
  Flash_embedSWF("animalsounds.swf");
</SCRIPT>

Next: How to use an invisible frame

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: May 21, 2001
Revised: May 21, 2001

URL: http://www.webreference.com/js/column84/5.html