我在尝试使用swfobject嵌入文件与我的html进行通信时遇到了麻烦。当我使用AC_RunActiveContent以标准方式嵌入swfs时,它有效,任何想法为什么会这样?基本上,沿着底部的导航按钮可以阻止swfs在点击时播放。我真的很感激任何帮助!
<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>
感谢您的反馈!
答案 0 :(得分:1)
在你的SWF中,你导入了flash.external.ExternalInterface吗?
如果没有,您需要这样做,然后在SWF中公开'commandFlash'方法。您可能还需要在您的域上进行此类通信。
import flash.external.ExternalInterface;
System.security.allowDomain('*');
var flashAvailable:Boolean = ExternalInterface.available;
ExternalInterface.addCallback('commandFlash', null, commandFlash);
function commandFlash( args... ){
//
}
除了上述内容之外,也许您的SWF隐藏了display:none;在某个时候在页面上,然后透露?这在过去的Firefox中给我带来了一些陌生感。
(不确定您是否在SWF中使用AS2 / 3)
答案 1 :(得分:1)
您的SWFObject代码有错误:它缺少快速安装参数。
swfobject.embedSWF("images/blank1.swf", "blank1", "747", "420", "9.0.0", "expressinstall.swf", flashvars, params, attributes);
swfobject.embedSWF("images/blank2.swf", "blank2", "747", "420", "9.0.0", "expressinstall.swf", flashvars, params, attributes);
swfobject.embedSWF("images/blank3.swf", "blank3", "747", "420", "9.0.0", "expressinstall.swf", flashvars, params, attributes);
当然,您需要将“expressinstall.swf”替换为expressinstall.swf文件的正确路径。如果您不想使用快速安装,只需添加false
布尔值。
swfobject.embedSWF("images/blank1.swf", "blank1", "747", "420", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF("images/blank2.swf", "blank2", "747", "420", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF("images/blank3.swf", "blank3", "747", "420", "9.0.0", false, flashvars, params, attributes);
答案 2 :(得分:0)
排序 - 设法完成它(见下文),感谢大家的投入/支持! 现在唯一的问题是Internet Explorer在触发stopFlash命令的按钮上返回错误“对象不支持此属性或方法”,但至少它仍然有效。哎呀。
var flashvars = {};
var params = {wmode:"opaque", allowscriptaccess:"always" };
var attributes = {};
swfobject.embedSWF("images/clients/blank1.swf", "blank1", "747", "420", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF("images/clients/blank2.swf", "blank2", "747", "420", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF("images/clients/blank3.swf", "blank3", "747", "420", "9.0.0", false, flashvars, params, attributes);
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();
return true;
}