I’m using the following code to trigger the playing of a swf file when an image is clicked. It works great, but I want to have multiple swf files that are each triggered by diffent images.
<script language="JavaScript">
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
function PlayFlashMovie()
{
var flashMovie=getFlashMovieObject("Flash1");
flashMovie1.Play();
}
</script>
then the movie is triggered:
<div class="buttonimage1" style="background-color: #FFFFFF;">
<img src="icon1-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" >
I want to add this so that (for example) clicking buttonimage2 would trigger “movie 2” and
buttonimage3 would trigger “movie 3” etc…
<div class="buttonimage2" style="background-color: #FFFFFF;">
<img src="icon2-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" >
<div class="buttonimage3" style="background-color: #FFFFFF;">
<img src="icon3-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" >
</div>
How can I set the getFlashMovieOject function for multiple movie names?
I’ve tried a couple of things but seem to be missing something and I’m pretty new to js.
A little help would be greatly appreciated.
Thanks
You could have the
PlayFlashMoviefunction take an argument:And then pass it like so:
etc