User Guide
LocalConnection 727
Example
The following example displays a status message about whether the SWF file connects to
another local connection object called
lc_name. A TextInput component called name_ti, a
TextArea instance called
status_ta and a Button instance called send_button are used to
display content.
var sending_lc:LocalConnection;
var sendListener:Object = new Object();
sendListener.click = function(evt:Object) {
sending_lc = new LocalConnection();
sending_lc.onStatus = function(infoObject:Object) {
switch (infoObject.level) {
case 'status' :
status_ta.text = "LocalConnection connected successfully.";
break;
case 'error' :
status_ta.text = "LocalConnection encountered an error.";
break;
}
};
sending_lc.send("lc_name", "sayHello", name_ti.text);
};
send_button.addEventListener("click", sendListener);
See also
send (LocalConnection.send method), onStatus (System.onStatus handler)
send (LocalConnection.send method)
public send(connectionName:String, methodName:String, [args:Object]) :
Boolean
Invokes the method named method on a connection opened with the
LocalConnection.connect(connectionName) command (the receiving LocalConnection
object). The object used with this command is called the sending LocalConnection object.
The SWF files that contain the sending and receiving objects must be running on the same
client computer.
There is a 40 kilobyte limit to the amount of data you can pass as parameters to this
command. If the command returns
false but your syntax is correct, try dividing the
LocalConnection.send() requests into multiple commands, each with less than 40K of
data.