EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 440

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
440 Chapter 12: ActionScript Dictionary
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 = new LocalConnection();
aLocalConnection.Trace = function(aString)
{
aTextField = aTextField + aString + newline;
}
aLocalConnection.Clear = function()
{
aTextField = "";
}
aLocalConnection.connect("trace");
stop();
SWF 1 contains the following code attached to a button labeled PushMe. When you push the
button, you see the sentence “The button was pushed.” in the receiving SWF file.
on (press)
{
var lc = new LocalConnection();
lc.send("trace", "Trace", "The button was pushed.");
delete lc;
}
SWF 2 contains an input text box with a var name of myText, and the following code attached to
a button labeled Copy. When you type some text and then push the button, you see the text you
typed in the receiving SWF file.
on (press)
{
_parent.lc.send("trace", "Trace", _parent.myText);
_parent.myText = "";
}
SWF 3 contains the following code attached to a button labeled Clear. When you push the
button, the contents of the trace window in the receiving SWF file are cleared (erased).
on (press)
{
var lc = new LocalConnection();
lc.send("trace", "Clear");
delete lc;
}
See also
LocalConnection.send()

Table of Contents

Related product manuals