2

我需要将文本从嵌入式 SWF(Web 浏览器)发送到基于 AIR 的桌面应用程序。我做了文档中解释的所有事情,但我无法建立连接。

有没有人看到我做错了什么或者可以指出一个可行的例子?

来自主权财富基金:

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");
    } 

谢谢你。乌里

4

1 回答 1

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("_myConne‌​ction");

airtestAIR 应用程序的应用程序 ID在哪里。使用_本地连接名称前的符号来支持不可预知的域名(它将在调试模式下和通过 http 工作)。

于 2013-01-10T11:24:48.807 回答