简体   繁体   English

来自javascript的ActionScript调用引发异常

[英]Actionscript call from javascript throws an exception

I know this subjet isn't new at all but i'm going to be crazy that it doesn't work at all. 我知道这架喷气式飞机根本不是新的,但我将为它根本不起作用而感到疯狂。 So I create a "KISS" (Keep It Stupide Simple) sample just to see if it may be something from the original SWF or just a real problem... 因此,我创建了一个“ KISS”(保持简单简单)样本,只是看它可能是原始SWF的内容还是真正的问题...

HTML is hosted on web site A (actually the Javascript too, but this last one will be moved on web site C) en the swf is hosted at web site B. HTML托管在网站A上(实际上也是Javascript,但是最后一个将在网站C上移动),而swf托管在网站B上。

Here the swf (from Adobe so it should work...) : 这是瑞士法郎(来自Adobe,所以应该可以使用...):

import flash.external.*;

Security.allowDomain("*");

var methodName:String = "goHome";
var instance:Object = null;
var method:Function = goToAdobe;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);

var txtField:TextField = this.createTextField("txtField", this.getNextHighestDepth(), 0, 0, 200, 50);
txtField.border = true;
txtField.text = wasSuccessful.toString();

function goToAdobe() {
    txtField.text = "http://www.adobe.com";
    getURL("http://www.adobe.com", "_self");
}

stop();

and the HTML/Javascript : (HTML generated from Flash itself with FSCommand support (so allowScriptAccess is "always") and the javascript from Adobe too) 和HTML / Javascript :(由Flash本身生成的HTML带有FSCommand支持(因此allowScriptAccess始终为“)”,Adobe的javascript也是如此)

<!-- saved from url=(0013)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>KISS</title>
</head>
<body bgcolor="#ffffff">
<script language="JavaScript">
<!--
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function KISS_DoFSCommand(command, args) {
 var KISSObj = isInternetExplorer ? document.all.KISS : document.KISS;

}
// Hook pour Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
 document.write('<script language=\"VBScript\"\>\n');
 document.write('On Error Resume Next\n');
 document.write('Sub KISS_FSCommand(ByVal command, ByVal args)\n');
 document.write(' Call KISS_DoFSCommand(command, args)\n');
 document.write('End Sub\n');
 document.write('</script\>\n');
}
//-->
</script>
<form>
    <input type="button" onclick="callExternalInterface()" value="Call ExternalInterface" />
</form>
<script>
function callExternalInterface() {
    thisMovie("KISS").goHome();
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
</script>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="KISS" width="550" height="400" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="http://www.adopsmanager.com/KISS.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="http://www.adopsmanager.com/KISS.swf" quality="high" bgcolor="#ffffff" width="550" height="400" swLiveConnect=true id="KISS" name="KISS" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer_fr" />
</object>
</body>
</html>

Thanks ! 谢谢 !

Could it be that 可能是

 System.allowDomain

was not in the original example? 不是原来的例子吗? It looks like the rest of the example is actionscript2 code, that would mean the allowDomain call is: 看起来该示例的其余部分是actionscript2代码,这意味着allowDomain调用为:

System.security.allowDomain

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM