admin管理员组文章数量:1355559
I'm trying to call a function declared with ExternalInterface in a Flash swf, using JavaScript. It worked once, but all of a sudden, it stopped working.
I have a debug version of the Flash Player, but no errors occur in Flash. Not even a "Security Sandbox Error" or something. The only error I get is the following error in JavaScript Error: Error in Actionscript. Use a try/catch block to find error.
I'm using AS3, exporting for Flash Player 10 and testing on Firefox 3/Safari 4, on a Mac.
Any assistance would be greatly appreciated.
I'm trying to call a function declared with ExternalInterface in a Flash swf, using JavaScript. It worked once, but all of a sudden, it stopped working.
I have a debug version of the Flash Player, but no errors occur in Flash. Not even a "Security Sandbox Error" or something. The only error I get is the following error in JavaScript Error: Error in Actionscript. Use a try/catch block to find error.
I'm using AS3, exporting for Flash Player 10 and testing on Firefox 3/Safari 4, on a Mac.
Any assistance would be greatly appreciated.
Share Improve this question asked Mar 27, 2009 at 17:32 evilpenguinevilpenguin 5,4886 gold badges43 silver badges50 bronze badges4 Answers
Reset to default 7Check out ExternalInterface.marshallExceptions. It should allow you to see more details about the error.
Kinda tricky to help you solve something that 'worked once'. But using ExternalInterface is pretty straightforward -- here's what I do:
in AS3: something like
...
if (ExternalInterface.available) ExternalInterface.addCallback("search", jsSearch);
...
private function jsSearch(term:String):void
{
new Search(data);
}
in JS: something like
...
var term = $('input#search').val();
$("#swfobject").get(0).search(term);
....
- Make sure the javascript and the SWF are on the same domains otherwise use a crossdomain.xml
- Make sure you have added the allowScriptAccess parameter to the flash embed
- If you run it locally you may (but don't think it will change anything) add the location to flash players trusted ones (in the security panel).
in your as
import flash.external.*;
ExternalInterface.call("return_me_some_value()");
and in your html
<script>
var super_var = 'something';
function return_me_some_value() {
return super_var;
}
</script>
本文标签: calling a Flash ExternalInterface with JavaScriptStack Overflow
版权声明:本文标题:calling a Flash ExternalInterface with JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743958566a2568589.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论