swfobject 不与 html 通信
我在尝试让 swfobject 嵌入文件与我的 html 进行通信时遇到问题。当我使用 AC_RunActiveContent 以标准方式嵌入 swfs 时,它可以工作,有什么想法为什么会这样吗?基本上,底部的导航按钮在单击时会阻止 swf 播放。我真的很感激任何帮助!
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.play = "true";
params.loop = "false";
params.menu = "true";
params.quality = "high";
params.scale = "showall";
params.wmode = "opaque";
params.bgcolor = "#ffffff";
params.devicefont = "false";
params.allowscriptaccess = "always";
var attributes = {};
swfobject.embedSWF("images/blank1.swf", "blank1", "747", "420", "9.0.0", flashvars, params, attributes);
swfobject.embedSWF("images/blank2.swf", "blank2", "747", "420", "9.0.0", flashvars, params, attributes);
swfobject.embedSWF("images/blank3.swf", "blank3", "747", "420", "9.0.0", flashvars, params, attributes);
</script>
<script language="javascript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function stopFlash(){
getFlashMovie("blank1").commandFlash();
getFlashMovie("blank2").commandFlash();
getFlashMovie("blank3").commandFlash();
}
HTML:
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="747" height="420">
<param name="movie" value="images/blank1.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="images/blank1.swf" width="747" height="420">
<!--<![endif]-->
<img src="images/blank1.jpg" alt="" width="747px" height="420px" />
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<div id="navigation">
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-previous"></div></a>
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-next"></div></a>
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-first"></div></a>
</div>
感谢您的反馈!
I'm having trouble trying to get swfobject embedded files to communicate with my html. When I embed swfs the the standard way using AC_RunActiveContent it works, any ideas why this would be ? Basically the navigation buttons along the bottom stop the swfs from playing when their clicked. I'd really appreciate any help!
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.play = "true";
params.loop = "false";
params.menu = "true";
params.quality = "high";
params.scale = "showall";
params.wmode = "opaque";
params.bgcolor = "#ffffff";
params.devicefont = "false";
params.allowscriptaccess = "always";
var attributes = {};
swfobject.embedSWF("images/blank1.swf", "blank1", "747", "420", "9.0.0", flashvars, params, attributes);
swfobject.embedSWF("images/blank2.swf", "blank2", "747", "420", "9.0.0", flashvars, params, attributes);
swfobject.embedSWF("images/blank3.swf", "blank3", "747", "420", "9.0.0", flashvars, params, attributes);
</script>
<script language="javascript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function stopFlash(){
getFlashMovie("blank1").commandFlash();
getFlashMovie("blank2").commandFlash();
getFlashMovie("blank3").commandFlash();
}
HTML:
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="747" height="420">
<param name="movie" value="images/blank1.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="images/blank1.swf" width="747" height="420">
<!--<![endif]-->
<img src="images/blank1.jpg" alt="" width="747px" height="420px" />
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<div id="navigation">
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-previous"></div></a>
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-next"></div></a>
<a href="#" name="btn" onClick="stopFlash()"><div id="slideshow-first"></div></a>
</div>
Thanks for any feedback!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在你的SWF中,你导入了flash.external.ExternalInterface吗?
如果没有,您需要这样做,然后在 SWF 中公开“commandFlash”方法。您可能还需要在您的域上允许这种通信。
除上述情况外,也许您的 SWF 被隐藏为 display:none;在某个时刻出现在页面上,然后显示出来?这在过去给我在 Firefox 中带来了一些奇怪的感觉。
(不确定您的 SWF 中是否使用 AS2/3)
In your SWF, have you imported flash.external.ExternalInterface?
If not, you'll need to do that and then also expose the 'commandFlash' method in your SWF. You may need to allow this kind of communication on your domain, too.
Other than the above, perhaps your SWF is hidden with display:none; on the page at some point, and then revealed? This has caused some strangeness for me in Firefox in the past.
(not sure if you're using AS2/3 in your SWF)
您的 SWFObject 代码有错误:它缺少快速安装参数。
当然,您需要将“expressinstall.swf”替换为expressinstall.swf 文件的正确路径。如果您不想使用快速安装,只需输入
false
布尔值即可。Your SWFObject code has errors: it's missing the express install parameter.
Of course you need to replace "expressinstall.swf" with the correct path to your expressinstall.swf file. If you don't want to use express install, just put a
false
boolean instead.已排序 - 设法解决(见下文),感谢大家的投入/支持!
现在唯一的问题是 Internet Explorer 在触发 stopFlash 命令的按钮上返回错误“对象不支持此属性或方法”,但至少它仍然有效。咕噜。
Sorted - managed to work it out (see below) thanks to everyone for their input/support!
Only problem now is internet explorer is returning an error "object doesn't support this property or method" on the buttons that fire the stopFlash command, but at least it still works. Grrr.