swfobject 不与 html 通信

发布于 2024-11-16 16:04:35 字数 2210 浏览 2 评论 0原文

我在尝试让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不念旧人 2024-11-23 16:04:35

在你的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)

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.

import flash.external.ExternalInterface;

System.security.allowDomain('*');
var flashAvailable:Boolean = ExternalInterface.available;

ExternalInterface.addCallback('commandFlash', null, commandFlash);
function commandFlash( args... ){
  //
}

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)

甜扑 2024-11-23 16:04:35

您的 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);

Your SWFObject code has errors: it's missing the express install parameter.

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);

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.

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);
尤怨 2024-11-23 16:04:35

已排序 - 设法解决(见下文),感谢大家的投入/支持!
现在唯一的问题是 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;
}

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.

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文