不知道我哪里出错了,现在只是在本地尝试一下。谢谢。
sendLC.swf 确实返回,LocalConnection.send() 成功
这是我从 Flash 中得到的错误。错误 #2044:未处理的 AsyncErrorEvent:。text=Error #2095: flash.net.LocalConnection 无法调用回调 myMethod。error=ReferenceError:错误 #1069:在 flash.net.LocalConnection 上找不到属性 myMethod,并且没有默认值。
发送LC.swf的代码:
import flash.net.LocalConnection
var sendingLC:LocalConnection;
sendingLC = new LocalConnection();
sendingLC.allowDomain('*');
Security.allowDomain("*");
sendBtn.addEventListener(MouseEvent.CLICK, sendIt);
function sendIt(eventObj:MouseEvent):void {
sendingLC.send('myConnection', 'myMethod');
}
sendingLC.addEventListener(StatusEvent.STATUS, statusHandler);
function statusHandler (event:StatusEvent):void
{
switch (event.level)
{
case "status" :
textArea.text = ("LocalConnection.send() succeeded");
break;
case "error" :
textArea.text = ("LocalConnection.send() failed");
break;
}
}
接收LC.swf的代码:
import flash.net.LocalConnection
var receivingLC:LocalConnection;
receivingLC = new LocalConnection();
receivingLC.allowDomain('*');
Security.allowDomain("*");
receivingLC.connect('myConnection');
function myMethod():void {trace('Hello World')}