当 jQuery 引用 .swf 时,如何调用 Actionscript 函数?

发布于 2024-08-05 06:20:51 字数 397 浏览 2 评论 0原文

我有一个 .swf,我使用 jQuery SWF 对象插件 (http://jquery.thewikies 将其嵌入到 HTML 中。 com/swfobject)。我在 .swf 中有许多函数需要从 javascript 函数中调用。我通过调用 flash.external.ExternalInterface.addCallback() 使 JavaScript 可以访问这些 ActionScript 函数。然而当我打电话时什么也没有发生。我以前也遇到过这种情况,似乎当您从 jQuery 引用 .swf 时,您无法调用 flash 函数。有没有办法解决这个问题(除了不使用 jQuery)?

谢谢。

I have an .swf that I am embedding into HTML using the jQuery SWF Object plugin (http://jquery.thewikies.com/swfobject). I have a number of functions within the .swf that I need to call from within javascript functions. I've made these actionscript functions accessible to javascript by calling flash.external.ExternalInterface.addCallback(). Yet nothing happens when I make the call. I've had this happen before and it seems to be that when you reference the .swf from jQuery, you can't call flash functions. Is there anyway around this (aside from not using jQuery)?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

玩套路吗 2024-08-12 06:20:52
$('#id_you_gave_swfobject').your_externalInterface_callback();

在 jQuery 中

$('#id_you_gave_swfobject').your_externalInterface_callback();

In jQuery

蝶舞 2024-08-12 06:20:51

我从未使用过 jquery swfobject 插件,但如果您在嵌入代码中添加 id 参数,您可以通过以下方式访问 swf

swf = document.getElementById("player"+i);
swf.callToFlash();

I've never used the jquery swfobject plugin but if you give add an id param in the embed code you can access the the swf through

swf = document.getElementById("player"+i);
swf.callToFlash();
夜巴黎 2024-08-12 06:20:51

我也有同样的问题。您可以使用 $('#myflashelement').context.myactionscriptfunction(arg) 来修复它。
为了方便起见,我制作了一个 jQuery“插件”来调用它们,并且在我的所有代码中不依赖于 context

(function ($) {
    $.fn.callAS = function() {
        var func = arguments[0];
        var args = Array.prototype.slice.call(arguments, 1);
        return this.context[func].apply(this.context, args);
    };
})(jQuery);

您可以使用 $('#myflashelement').callAS(' 来调用它myactionscriptfunction', arg)

I had the same problem. You can use $('#myflashelement').context.myactionscriptfunction(arg) to fix it.
For convenience I made a jQuery 'plugin' to call them and to not rely on context in all of my code:

(function ($) {
    $.fn.callAS = function() {
        var func = arguments[0];
        var args = Array.prototype.slice.call(arguments, 1);
        return this.context[func].apply(this.context, args);
    };
})(jQuery);

You can call it with $('#myflashelement').callAS('myactionscriptfunction', arg).

尬尬 2024-08-12 06:20:51
$('#myflashElement')[0].myASFunction(var1, var2);

为我工作

$('#myflashElement')[0].myASFunction(var1, var2);

works for me

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