actionscript-3 – As3 – SWF和AIR桌面应用之间的LocalConnection

前端之家收集整理的这篇文章主要介绍了actionscript-3 – As3 – SWF和AIR桌面应用之间的LocalConnection前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要从嵌入式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");
    }

谢谢.
乌利

解决方法

工作代码是:

AIR:
    var localConnection:LocalConnection = new LocalConnection();
    localConnection.send("_myConnection","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");

其中airtest是AIR应用程序的应用程序ID.在本地连接名称之前使用_符号来支持不可预测的域名(它将在调试模式和http中工作).

猜你在找的Flash相关文章