我需要从嵌入式SWF(Web浏览器)向基于AIR的桌面应用程序发送文本。 我完成了documentation中解释的所有内容,但我无法建立连接。
有人看到我做错了什么或者能指出一个有效的例子吗?
来自SWF:
function startConnection(e:Event=null):void
{
var localConnection:LocalConnection
localConnection = new LocalConnection();
localConnection.client = this;
localConnection.allowDomain("app#com.example.desktop");
var textToSend = "Hello world! Source: http://www.foobar.com";
localConnection.send("app#com.example.desktop:connectionName", "methodName",textToSend);
}
从AIR桌面应用程序:
function onBrowserInvoke (event:BrowserInvokeEvent):void{
var localConnection:LocalConnection
localConnection = new LocalConnection();
localConnection.client = this
localConnection.allowDomain("example.com");
localConnection.connect("connectionName");
}
谢谢。 乌利
答案 0 :(得分:2)
工作代码是:
AIR:
var localConnection:LocalConnection = new LocalConnection();
localConnection.send("_myConnection", "methodName", "Hello world! Source: http://www.foobar.com");
SWF:
var localConnection:LocalConnection = new LocalConnection();
localConnection.allowDomain("app#airtest"); //or use "*" wildcard to allow any domains and AIR applications
localConnection.client = this;
localConnection.connect("_myConnection");
其中airtest
是AIR应用程序的应用程序ID。在本地连接名称之前使用_
符号来支持不可预测的域名(它将在调试模式和http中工作)。