0

For some reason, the ExternalInterface.avaiable shows true, but it won't call alert(). Can anyone shed some light to this problem?

private function checkEI():void {
     eiStatus = ExternalInterface.available.toString();
     ExternalInterface.call("alert", "hi");
}

My config is here:

var params = {
    menu: "false",
    scale: "noScale",
    allowFullscreen: "true",
    allowScriptAccess: "always",
    bgcolor: "",
    wmode: "direct" // can cause issues with FP settings & webcam
};

Looks like it has to do with not being in a webserver and the html file just being opened directly by the browser. Is there any way to get it to work without a webserver?

Benny
  • 2,250
  • 4
  • 26
  • 39
LordZardeck
  • 7,953
  • 19
  • 62
  • 119
  • could you paste your `alert` function? – Benny Sep 03 '11 at 07:21
  • the alert function is the browser alert. everything works IF i'm running it from the web server instead of just opening the file. I'm sure it has something to do with a security policy or something. – LordZardeck Sep 07 '11 at 02:18

3 Answers3

0

Here's my answer that I posted a while ago. Hope it helps.

Extract:

I figured out that for some reason ExternalInterface.call doesn't work on a file:// and needs http(s)://

So, anybody who is facing this problem, get your yourself a webserver(Apache) or a GAE for testing these kinds of things

Community
  • 1
  • 1
Bleeding Fingers
  • 6,993
  • 7
  • 46
  • 74
0

Try to specify both id and classid in embed parameters. It helped me in all the browsers (especially IE).

moropus
  • 3,672
  • 1
  • 22
  • 30
-1

Have you tried

ExternalInterface.call("javascript:alert", "hi");

On second thought, Flash's security policy disallows the swf from calling a javascript in an html over the file protocol. You will get this error: #2060: Security sandbox violation: ExternalInterface caller file: c:/test.swf cannot access file: c:\testhtml.htm

I believe a similar question also exists at Does ExternalInterface work on the file: protocol?

Community
  • 1
  • 1
Pranav Hosangadi
  • 23,755
  • 7
  • 44
  • 70