Tom
Tom

Reputation: 8180

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.addCallback method fail locally. It works on a web server, or in the dev folder. But not in an arbitrary local folder.

Upvotes: 1

Views: 3150

Answers (3)

Philipp Kyeck
Philipp Kyeck

Reputation: 18850

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

Upvotes: 1

Allan
Allan

Reputation: 1083

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.

Upvotes: 1

Tom
Tom

Reputation: 8180

Add as a trusted location the folder where your swf/html reside. Right click the Flash Player>Global Settings>Advanced>Trusted Locations.

Upvotes: 2

Related Questions