User Guide

Sending messages to and from Flash Player 285
theSocket.send(myXML);
}
//button sends data
sendButton.onRelease = function() {
sendData();
};
//traces data returned from socket connection
theSocket.onData = function(msg:String):Void {
trace(msg);
};
For more information, see the “XMLSocket class” entry in Flash ActionScript Language Reference.
Sending messages to and from Flash Player
To send messages from a SWF file to its host environment (for example, a web browser, a
Macromedia Director movie, or the stand-alone Flash Player), you can use the
fscommand()
function. This function lets you extend your SWF file by using the capabilities of the host. For
example, you could pass an
fscommand() function to a JavaScript function in an HTML page
that opens a new browser window with specific properties.
To control a SWF file in Flash Player from web browser scripting languages such as JavaScript,
VBScript, and Microsoft JScript, you can use Flash Player methods—functions that send
messages from a host environment to the SWF file. For example, you could have a link in an
HTML page that sends your SWF file to a specific frame.For more information, see the following
topics:
“Using fscommand()” on page 285
About Flash Player methods” on page 287
About using JavaScript to control Flash applications” on page 288
Using fscommand()
You use the
fscommand() function to send a message to whichever program is hosting Flash
Player, such as a web browser.
Note: Using fscommand to call Javascript does not work on the Safari or Internet Explorer browsers for
the Macintosh.
The fscommand() function has two parameters: command and arguments. To send a message to
the stand-alone version of Flash Player, you must use predefined commands and arguments. For
example, the following event handler sets the stand-alone player to scale the SWF file to the full
monitor screen size when the button is released:
my_btn.onRelease = function() {
fscommand("fullscreen", true);
};