AS3 LocalConnection:功能未触发
AS3 LocalConnection: function is not firing
我正在构建一个将文本字符串发送到 swf 文件的 AIR 应用程序。当我将发送方和接收方应用程序导出到 swf 并在 Flash 播放器中 运行 时,一切正常。但是,当将发件人应用程序发布到 AIR 时,事情就不再起作用了。
我认为连接有效,因为没有错误消息。但是 reciever swf 上的函数不会触发。
这是我的 AIR(发件人)代码:
import flash.net.LocalConnection;
import flash.events.MouseEvent;
var conn:LocalConnection;
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onLocalConnError);
function send_it(event:MouseEvent):void
{
conn.send('_connection', 'fire','myString');
}
function onLocalConnError(e:StatusEvent):void
{
teksti.text = e.toString();
}
btn.addEventListener(MouseEvent.CLICK, send_it);
接收方SWF:
import flash.net.LocalConnection;
import flash.events.MouseEvent;
var conn:LocalConnection;
function connect(event:MouseEvent):void
{
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onLocalConnError);
conn.allowDomain("app#fi.myapp");
conn.client = this;
conn.connect('_connection');
this.addEventListener(Event.CLOSE, closeConnection);
}
btn.addEventListener(MouseEvent.CLICK, connect);
function onLocalConnError(e:StatusEvent):void
{
my_text.text = e.toString();
}
function fire(txt:String):void
{
my_text.text = txt;
}
function closeConnection(e:Event = null):void
{
conn.close();
}
知道我做错了什么吗?
您必须在 send
-调用中识别接收应用程序和连接名称:
conn.send('app#YourReceivingAppName:_connection', 'fire','myString');
问候
我正在构建一个将文本字符串发送到 swf 文件的 AIR 应用程序。当我将发送方和接收方应用程序导出到 swf 并在 Flash 播放器中 运行 时,一切正常。但是,当将发件人应用程序发布到 AIR 时,事情就不再起作用了。
我认为连接有效,因为没有错误消息。但是 reciever swf 上的函数不会触发。
这是我的 AIR(发件人)代码:
import flash.net.LocalConnection;
import flash.events.MouseEvent;
var conn:LocalConnection;
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onLocalConnError);
function send_it(event:MouseEvent):void
{
conn.send('_connection', 'fire','myString');
}
function onLocalConnError(e:StatusEvent):void
{
teksti.text = e.toString();
}
btn.addEventListener(MouseEvent.CLICK, send_it);
接收方SWF:
import flash.net.LocalConnection;
import flash.events.MouseEvent;
var conn:LocalConnection;
function connect(event:MouseEvent):void
{
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onLocalConnError);
conn.allowDomain("app#fi.myapp");
conn.client = this;
conn.connect('_connection');
this.addEventListener(Event.CLOSE, closeConnection);
}
btn.addEventListener(MouseEvent.CLICK, connect);
function onLocalConnError(e:StatusEvent):void
{
my_text.text = e.toString();
}
function fire(txt:String):void
{
my_text.text = txt;
}
function closeConnection(e:Event = null):void
{
conn.close();
}
知道我做错了什么吗?
您必须在 send
-调用中识别接收应用程序和连接名称:
conn.send('app#YourReceivingAppName:_connection', 'fire','myString');
问候