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
|