20
Getting Started
Opening a connection to the server
Open a new file in the Flash authoring environment, and then add the client-side
ActionScript commands to connect to the server.
To connect to Flash Media Server:
1.
In a new Flash application, begin opening a connection by issuing the following command:
my_nc = new NetConnection();
2.
Follow this command with a
connect
command:
my_nc.connect(
targetURI
);
In this basic syntax for
NetConnection.connect()
(omitting optional parameters),
targetURI
is the Uniform Resource Identifier (URI) of an application on the Flash Media
Server that should run when the connection is made. To specify
targetURI
, use one of
the following formats (items in brackets are optional):
rtmp://localhost[:port]/
appName
[/
instanceName
]
The use of
localhost
indicates that the server is running on your local computer.
rtmp://
host
[:
port
]/
appName
[/
instanceName
]
To connect to a virtual host other than the default virtual host, specify the virtual host’s
name in
host
. If the server is running on your local computer, you can use
“localhost”
as the host name in the URI; this is often convenient during application development.
For example, the following code uses the
new NetConnection
constructor to create a new
connection object. Then, the object is connected to the server with the call to
my_nc.connect()
.
// Makes a new connection object
my_nc = new NetConnection();
/* Connects to the instance named appInstance
of the application named appName
located on the Flash Media Server
/* that is running on the virtual host myServer.myDomain.com
my_nc.connect("rtmp://myServer.myDomain.com/appName/appInstance");
NO
TE
In all syntax examples for
targetURI
, you must specify
rtmp
(the Real-Time
Messaging Protocol) as the protocol for the connection. If you omit it, Flash Player
assumes you want to make an HTTP connection to an application server, and your
connection fails.
Summary of Contents for FLASH MEDIA SERVER 2-DEVELOPING MEDIA
Page 1: ...Developing Media Applications ...
Page 6: ...6 ...
Page 10: ...10 About This Manual ...
Page 36: ...36 Flash Media Server Architecture ...
Page 80: ...80 Debugging and Monitoring Applications ...
Page 106: ...106 Application Development Tips and Tricks ...
Page 114: ...114 ...