AS3 LocalConnection:函数未触发

时间:2015-06-16 12:13:09

标签: actionscript-3 flash air

我正在构建一个AIR文件,它将文本字符串发送到swf文件。当我将发件人和接收器应用程序导出到swf并在Flash播放器中运行时,一切正常。但是当将发件人应用程序发布到AIR时,事情就不再起作用了。

我认为连接有效,因为没有错误消息。但接收器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();
}

任何想法我做错了什么?

1 个答案:

答案 0 :(得分:0)

您必须在接收应用中标识<?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once './php/doctype.php'; ?> 中的连接名 - 呼叫:

send

问候