使用javascript函数调用来播放多个swf文件 [英] using javascript function call to play multiple swf files
问题描述
我使用以下代码触发单击图像时播放swf文件。它工作的很好,但我想要有多个swf文件,每个swf文件都由不同的图像触发。
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();" >
我想添加这个(例如)单击buttonimage2会触发电影2,
buttonimage3会触发电影3等... ...
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>
如何为多个电影名称设置getFlashMovieOject函数?
我尝试了一些东西,但似乎缺少一些东西,我对js很新。
一点帮助将不胜感激。
谢谢
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
推荐答案
您可以使用 PlayFlashMovie
一个参数:
You could have the PlayFlashMovie
function take an argument:
function PlayFlashMovie(name) {
var flashMovie=getFlashMovieObject(name);
flashMovie.Play();
}
然后像这样传递:
And then pass it like so:
<img src="icon1-small.png" alt="icon 1" onmousedown="PlayFlashMovie('Flash1');" >
<img src="icon2-small.png" alt="icon 2" onmousedown="PlayFlashMovie('Flash2');" >
etc
这篇关于使用javascript函数调用来播放多个swf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!