MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 332

Actionscript language reference
Table of Contents

Advertisement

domain_txt.text = sendingDomain;
return true;
};
my_lc.allowInsecureDomain = function(sendingDomain:String) {
return (sendingDomain == this.domain());
}
my_lc.sayHello = function(name:String) {
welcome_txt.text = "Hello, "+name;
};
my_lc.connect("_mylc");
The following example sends a string to the previous SWF file and displays a status message about
whether the local connection was able to connect to the file. A TextInput component called
, a TextArea instance called
name_ti
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("_mylc", "sayHello", name_ti.text);
};
send_button.addEventListener("click", sendListener);
In the following example, the receiving SWF file, which resides in thisDomain.com, accepts
commands only from SWF files located in thisDomain.com or thatDomain.com:
var aLocalConn:LocalConnection = new LocalConnection();
aLocalConn.Trace = function(aString) {
aTextField += aString+newline;
};
aLocalConn.allowDomain = function(sendingDomain) {
return (sendingDomain == this.domain() || sendingDomain ==
"www.macromedia.com");
};
aLocalConn.connect("_mylc");
When published for Flash Player 7 or later, exact domain matching is used. This means that the
example will fail if the SWF files are located at www.thatDomain.com but will work if the files are
located at thatDomain.com.
See also
LocalConnection.connect(), LocalConnection.domain(), LocalConnection.send(),
MovieClip._url, MovieClipLoader.onLoadComplete,
332
Chapter 6: ActionScript Core Classes
and a Button instance called
status_ta
send_button
_parent
are

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flex

Table of Contents