336
Chapter 6: ActionScript Core Classes
If you are implementing communication between SWF files in different domains, specifying a
string for
connectionName
that begins with an underscore (_) will make the SWF with the
receiving LocalConnection object more portable between domains. Here are the two possible
cases:
•
If the string for
connectionName
does not begin with an underscore (_), Flash Player adds a
prefix with the superdomain and a colon (for example,
"myDomain:connectionName"
).
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,
"myDomain:connectionName"
). If the SWF with the receiving
LocalConnection object is moved to another domain, the player changes the prefix to reflect
the new superdomain (for example,
"anotherDomain:connectionName"
). All sending
LocalConnection objects would have to be manually edited to point to the new superdomain.
•
If the string for
connectionName
begins with an underscore (for example,
"_connectionName"
), Flash Player does not add a prefix to the string. This means that the
receiving and sending LocalConnection objects will use identical strings for
connectionName
.
If the receiving object uses
LocalConnection.allowDomain
to specify that connections from
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
connectionName
in
LocalConnection.send()
and
also the
LocalConnection.allowDomain
and
LocalConnection.domain()
entries.
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
Trace
in a receiving SWF file in the same domain. The receiving SWF file functions as a trace
window for the sending SWF file; it contains two methods that other SWF files can call—
Trace
and
Clear
. Buttons pressed in the sending SWF files call these methods with
specified parameters.
// Receiving SWF
var aLocalConnection:LocalConnection = new LocalConnection();
aLocalConnection.Trace = function(aString):String{
aTex= a 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
playback_pb
displays the playback progress of the MP3 file.
A Label component instance called
song_lbl
displays the name of the MP3 file. Buttons in
different SWF files will be used to control the playback using a LocalConnection object.
var playback_pb:mx.controls.ProgressBar;
var my_sound:Sound;
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...