更改一个Flash文件 [英] Changing a flash file
问题描述
我正在尝试开发一种方法,通过单击按钮将屏幕上显示的Flash文件更改为另一个文件。我已经能够做到这一点与JPG图像,但我不能让它与Flash文件工作。谁能帮忙?我将不胜感激。
下面是两个html:第一个更改jpg图像,它的工作原理,第二个我构建类似于flash文件一样,但它不起作用。
// Html 1.这会将图像1更改为图像2。它工作
$ b b
$ b函数changeSrc()
{
document.getElementById(myImage)。src = Image 2.jpg;
}
// Html 2.这是为了在点击时将Flash 1更改为Flash 2 。它不起作用
$ b函数changeSrc()
{
document.getElementById(myImage)。 src =Flash 2.swf;
}
$ p
$ b $ p
您需要使用embed或object标签的name属性来获取对嵌入式Flash文件的引用。使用id将无法正常工作。
但是有一个更简单的方法。如果您使用 swfObject 来嵌入您的swf,这可以像一个javascript调用。
< script type =text / javascript>
var flashvars = false;
var params = {
menu:false,
flashvars:name1 = hello& name2 = world& name3 = foobar
};
var attributes = {
id:myDynamicContent,
name:myDynamicContent
};
swfobject.embedSWF(myContent.swf,myContent,300,120,9.0.0,expressInstall.swf,flashvars,params,attributes);
< / script>
I am trying to develop a way to change a flash file displayed on the screen to another file by clicking a button. I have been able to do this with jpg images, but I can't get it to work with flash files. Can anyone help? I would greatly appreciate it. Below are two html's: the first one changes jpg images and it works, the second one I constructed to be similar to do the same with flash files but it does not work.
//Html 1. This changes Image 1 to Image 2 on click. It works
function changeSrc() { document.getElementById("myImage").src="Image 2.jpg"; }//Html 2. This is intended to change Flash 1 to Flash 2 on click. It does not work
function changeSrc() { document.getElementById("myImage").src="Flash 2.swf"; }
You need to use the name property of the embed or object tag to grab a reference to your embedded flash files. Using the id will not work.
But there is an easier way of doing this. if you use swfObject to embed your swfs, this can be as simple as one javascript call.
<script type="text/javascript">
var flashvars = false;
var params = {
menu: "false",
flashvars: "name1=hello&name2=world&name3=foobar"
};
var attributes = {
id: "myDynamicContent",
name: "myDynamicContent"
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
这篇关于更改一个Flash文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!