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

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

问题描述

我需要将文本从嵌入式 SWF(Web 浏览器)发送到基于 AIR 的桌面应用程序.我按照文档 但我无法建立连接.

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

谢谢.乌利

推荐答案

工作代码为:

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 是 AIR 应用程序的应用程序 ID.在本地连接名称前使用 _ 符号来支持不可预测的域名(它将在调试模式下和通过 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天全站免登陆