MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference page 410

Actionscript language reference
Table of Contents

Advertisement

If you are implementing communication between SWF files in different domains, specifying a
string for
connectionName
receiving LocalConnection object more portable between domains. Here are the two possible
cases:
If the string for
prefix with the superdomain and a colon (for example,
Although this ensures that your connection does not conflict with connections of the same
name from other domains, any sending LocalConnection objects must specify this
superdomain (for example,
LocalConnection object is moved to another domain, the player changes the prefix to reflect
the new superdomain (for example,
LocalConnection objects would have to be manually edited to point to the new superdomain.
If the string for
"_connectionName"
receiving and sending LocalConnection objects will use identical strings for
If the receiving object uses
any domain will be accepted, the SWF with the receiving LocalConnection object can be
moved to another domain without altering any sending LocalConnection objects.
For more information, see the discussion of
also the
LocalConnection.allowDomain
Note: Colons are used as special characters to separate the superdomain from the connectionName
string. A string for connectionName that contains a colon is not valid.
Example
The following example shows how a SWF file in a particular domain can invoke a method named
in a receiving SWF file in the same domain. The receiving SWF file functions as a trace
Trace
window for the sending SWF file; it contains two methods that other SWF files can call—
and
Trace
Clear
specified parameters.
// Receiving SWF
var aLocalConnection:LocalConnection = new LocalConnection();
aLocalConnection.Trace = function(aString):String{
aTextField += aString + newline;
}
aLocalConnection.Clear = function(){
aTextField = "";
}
aLocalConnection.connect("trace");
stop();
SWF 1 contains the following code, which creates a new Sound object that plays back an MP3
file at runtime. A ProgressBar called
A Label component instance called
different SWF files will be used to control the playback using a LocalConnection object.
var playback_pb:mx.controls.ProgressBar;
var my_sound:Sound;
410
Chapter 2: ActionScript Language Reference
that begins with an underscore (_) will make the SWF with the
does not begin with an underscore (_), Flash Player adds a
connectionName
"myDomain:connectionName"
"anotherDomain:connectionName"
begins with an underscore (for example,
connectionName
), Flash Player does not add a prefix to the string. This means that the
LocalConnection.allowDomain
. Buttons pressed in the sending SWF files call these methods with
playback_pb
song_lbl
"myDomain:connectionName"
). If the SWF with the receiving
to specify that connections from
in
connectionName
and
LocalConnection.domain()
displays the playback progress of the MP3 file.
displays the name of the MP3 file. Buttons in
). All sending
connectionName
LocalConnection.send()
entries.
).
.
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx

Table of Contents