2011-09-03 63 views
0

由於某種原因,ExternalInterface.avaiable顯示爲true,但不會調用alert()。任何人都可以解釋這個問題嗎?flex ExternalInterface不會執行調用()函數

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

我的配置是在這裏:

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

看起來它有一個網絡服務器的不是和HTML文件只被瀏覽器直接打開的事情。有沒有辦法讓它在沒有網絡服務器的情況下工作?

+0

可以粘貼你的'alert'功能? – Benny

+0

警報功能是瀏覽器警報。一切正常,如果我從Web服務器運行它而不是隻是打開文件。我相信它與安全策略或某事有關。 – LordZardeck

回答

0

嘗試在嵌入參數中指定idclassid。它幫助我在所有的瀏覽器(特別是IE)。

-1

你試過

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

關於第二個想法, Flash的安全策略,從調用了文件協議的HTML一個JavaScript不允許的瑞士法郎。您將收到此錯誤: #2060: Security sandbox violation: ExternalInterface caller file: c:/test.swf cannot access file: c:\testhtml.htm

我相信,類似的問題也存在於Does ExternalInterface work on the file: protocol?

+0

'ExternalInterface.call(「javascript:alert」,「hi」);'和 'ExternalInterface.call(「alert」,「hi」);' 有什麼區別? – Benny

+0

好吧,只是一個想法。 如果我從html調用JavaScript函數,我通常使用javascript:myFunction() –

+0

您可以使用。但你的回答不符合這個問題。 – Benny

0

Here's我的回答是我發佈前一陣子。希望能幫助到你。

提取物:

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