AS3 - SWF和AIR的桌面应用程序之间的LocalConnection [英] As3 - LocalConnection between SWF and AIR desktop app

查看:343
本文介绍了AS3 - SWF和AIR的桌面应用程序之间的LocalConnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要到从嵌入的SWF(网页浏览器)文本到基于AIR的桌面应用程序。 我所做的一切都像在<一个解释href="http://help.adobe.com/de_DE/FlashPlatform/reference/actionscript/3/flash/net/LocalConnection.html"相对=nofollow>文档但我无法建立连接。

I need to send a text from an embedded SWF (Web browser) to an AIR based desktop app. I did everything like explained in the documentation but I can't establish a connection.

是否有人看到我做错了什么,也可以点我一个工作的例子?

Does anybody see what I did wrong or can point me to a working example?

从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桌面应用程序:

From the AIR desktop app:

 function onBrowserInvoke (event:BrowserInvokeEvent):void{
    var localConnection:LocalConnection 
    localConnection = new LocalConnection(); 
    localConnection.client = this

    localConnection.allowDomain("example.com");
    localConnection.connect("connectionName");
    } 

感谢您。 乌利

推荐答案

工作code是:

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

其中, airtest 是应用程序ID的AIR应用程序。使用 _ 符号本地连接名称之前为支持联合国predictable域名(它会工作在调试模式,并通过HTTP)。

Where airtest is the app id for AIR application. Use the _ symbol before local connection name for supporting unpredictable domain names (it'll work in debug mode and via http).

这篇关于AS3 - SWF和AIR的桌面应用程序之间的LocalConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆