开发者

LocalConnection In AS3

开发者 https://www.devze.com 2023-02-11 12:02 出处:网络
I\'m trying to use LocalConnection in AS3 between two AS3 movies (made in CS5) but it doesn\'t seem to be working, here is the current code (each in frame1 (the only frame) of each movie on layer 1 (t

I'm trying to use LocalConnection in AS3 between two AS3 movies (made in CS5) but it doesn't seem to be working, here is the current code (each in frame1 (the only frame) of each movie on layer 1 (the only layer))

Sender:

import flash.external.ExternalInterface;
import flash.net.LocalConnection;

function sendtoview(con,val):String {
//create local connect开发者_如何学Cion 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')");

Note that I know the JavaScript connection to the ExternalInterface does work, I've tested it.

Receiver:

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')");

If you don't want to fix my code I'd still be happy with a working simple example (i've searched google for hours, none seem to be easy or simple.).


You might be better off checking out Grant Skinner's SwfBridge class. Makes LC's very easy to do.

http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html

0

精彩评论

暂无评论...
验证码 换一张
取 消