如何在.swf被jQuery引用时调用Actionscript函数? [英] How can I call an Actionscript function when the .swf is referenced by jQuery?

查看:146
本文介绍了如何在.swf被jQuery引用时调用Actionscript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.swf文件,使用jQuery SWF Object插件嵌入到HTML中( http:// jquery .thewikies.com / SWFObject的)。我在.swf中有一些函数需要在javascript函数中调用。我已经通过调用flash.external.ExternalInterface.addCallback()使这些动作脚本函数可以被JavaScript访问。然而,当我打电话时没有任何反应。我曾经遇到过这种情况,看起来当你从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)?

谢谢。

推荐答案

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

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

你可以用 $('#myflashelement')来调用callAS 'myactionscriptfunction',arg)

这篇关于如何在.swf被jQuery引用时调用Actionscript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆