How can I call an ActionScript function when jQuery is referencing the .swf?
I have a .swf that I am embedding in HTML using the jQuery SWF Object plugin ( http://jquery.thewikies.com/swfobject ). I have a number of functions inside .swf that I need to call from javascript functions. I made these actionscript functions available to javascript by calling flash.external.ExternalInterface.addCallback (). But nothing happens when I call. This has happened before, and it seems that when you reference the .swf from jQuery, you cannot call flash functions. Anyway, around this (other than using jQuery)?
Thank.
source to share
I had the same problem. You can use $('#myflashelement').context.myactionscriptfunction(arg)
to fix this. For convenience, I made a jQuery 'plugin' to call them and 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)
.
source to share