我正在尝试在两台AS3电影(CS5制作)中的AS3中使用LocalConnection,但它似乎不起作用,这里是当前代码(每个在电影上的每个电影的帧1(唯一的帧)) 1(唯一的一层))
发信人:
import flash.external.ExternalInterface;
import flash.net.LocalConnection;
function sendtoview(con,val):String {
//create local connection for sending text
var sending_lc:LocalConnection = new LocalConnection();
//put text from input into a var
sending_lc.addEventListener(StatusEvent.STATUS, err);
//send through specified connection, call specified method, send specified parameter
ExternalInterface.call("alert('Sending...')");
sending_lc.send("xivioview", "recieveText", val);
return "kk"
}
function err(msg) {
ExternalInterface.call("alert('" + msg + "')");
}
ExternalInterface.addCallback("sendtoview", sendtoview);
ExternalInterface.call("alert('Loaded')");
请注意,我知道与ExternalInterface的JavaScript连接确实有效,我已对其进行了测试。
接收器:
import flash.external.ExternalInterface;
import flash.net.LocalConnection;
var mLocalConnection:LocalConnection = new LocalConnection();
mLocalConnection.connect("xivioview");
mLocalConnection.client=this;
function recieveText(textRecieved:String) {
ExternalInterface.call("alert('Received!')");
ExternalInterface.call(textRecieved);
};
ExternalInterface.call("alert('Loaded')");
如果您不想修复我的代码,我仍然会对一个有效的简单示例感到满意(我已经搜索了谷歌数小时,似乎没有简单或简单。)
答案 0 :(得分:1)
你可能最好不要查看Grant Skinner的SwfBridge课程。使LC非常容易。
http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html