Sending Messages To And From Flash Player - MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

You can use the
connect()
from a server over a socket connection. The
with a web server port. The
socket connection.
When you invoke the
and keeps that connection open until one of the following happens:
The
close()
No more references to the XMLSocket object exist.
Flash Player exits.
The connection is broken (for example, the modem disconnects).
The following example creates an XML socket connection and sends data from the XML object
. To understand the script, read the commented lines (indicated by the characters
myXML
// Create a new XMLSocket object
sock = new XMLSocket();
// Call its connect() method to establish a connection with port 1024
// of the server at the URL
sock.connect("http://www.myserver.com", 1024);
// Define a function to assign to the sock object that handles
// the server's response. If the connection succeeds, send the
// myXML object. If it fails, provide an error message in a text
// field.
function onSockConnect(success){
if (success){
sock.send(myXML);
} else {
msg="There has been an error connecting to "+serverName;
}
}
// Assign the onSockConnect() function to the onConnect property
sock.onConnect = onSockConnect;
For more information, see the
on page
205.

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
function. This function lets you extend your SWF file by using the capabilities of the host. For
example, you could pass an
that opens a new browser window with specific properties.
To control a SWF 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. For example, you could have a link in an HTML
page that sends your SWF file to a specific frame.
and
send()
method passes an XML object to the server specified in the
send()
method, Flash Player opens a TCP/IP connection to the server
connect()
method of the XMLSocket class is called.
XMLSocket class
fscommand()
methods of the XMLSocket class to transfer XML to and
method establishes a socket connection
connect()
entry in
Chapter 12, "ActionScript Dictionary,"
function to a JavaScript function in an HTML page
Sending messages to and from Flash Player
):
//
fscommand()
185

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Questions and answers

Table of Contents