ExternalInterface.addCallback fails in local environment
I thought this question would answer my question, but I have applied the following fixes:
.as
Security.allowDomain("*");
Security.allowInsecureDomain("*");
.html
param name="allowScriptAccess" value="always" />
.js
params.allowscriptaccess = "always";
And I am still seeing the ExternalInterface.addCal开发者_Python百科lback
method fail locally.
It works on a web server, or in the dev folder. But not in an arbitrary local folder.
Add as a trusted location the folder where your swf/html reside. Right click the Flash Player>Global Settings>Advanced>Trusted Locations.
My guess is that the problem occurs when you load the .html page from a file://
URL (rather than running from a webserver, even localhost). This problem occurs because the Flash Player uses a different security sandbox for local files.
ExternalInterface.addCallback
cannot be used in the file://
sandbox unless you've got a Trusted Location set (as per Tom's answer; this may explain why it works in your dev folder if it is set to be a trusted location). Unfortunately, setting trusted locations can be a royal pain, so I prefer to set up a webserver on localhost to do my testing.
If your end goal is to deploy your html (and js, swf, etc.) to a webserver, then you should only encounter this problem during development (barring other cross-domain issues). But if you plan to distribute without a webserver (say burning the files to a DVD) then this will be a recurring problem.
try adding the folder in which you want to test this, to the security settings here: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
精彩评论