错误#2044:未处理的StatusEvent:。 level = error,code =从子swf向父swf发送值时

时间:2013-01-17 10:49:17

标签: actionscript-3 flash

我正在尝试将game.swf加载到main.swf中,当game.swf中的游戏完成后,它会通过玩游戏将得分和星星发送到main.swf,但问题是主要的.swf没有收到值并给出上述错误。请帮忙..

main.swf中用于接收得分和星标的代码是,

var receiving_lc:LocalConnection;
receiving_lc = new LocalConnection();
receiving_lc.connect("gameToEngine");
receiving_lc.client = this;

public function saveScore(score:int, stars:int):void
{
      trace("score="+score.toString()+ " stars="+ stars.toString());
}

game.swf中发送得分和星星的代码是,

var sending_lc:LocalConnection;
sending_lc = new LocalConnection();

function send_it(evt:MouseEvent):void
{
    sending_lc.send("gameToEngine", "saveScore", score, 2); 
}

my_btn.addEventListener(MouseEvent.MOUSE_UP, send_it);

请帮忙解决这个问题....

GOT解决了......

在fsbmain的帮助下......

只需要将receiving_lc设为全局变量......希望它有所帮助..

1 个答案:

答案 0 :(得分:1)

首先,尝试使用与域无关的本地连接名称,以_开头,在您的情况下为_gameToEngine,第二个添加状态事件侦听器处理StatusEvent错误:

sending_lc.addEventListener(StatusEvent.STATUS, onLCStatus);
protected function onLCStatus(event:StatusEvent):void
{
    trace("onLCStatus:", event.code);
}

UPD: 为了防止receive_lc的垃圾收集存储私有财产中的链接:

private var receiving_lc:LocalConnection;