By Brian Lesser, Giacomo Guilizzoni, Robert Reinhardt, Joey Lott, Justin Watkins
Book Price: $49.95 USD
£35.50 GBP
PDF Price: $39.99
Cover | Table of Contents | Colophon
http://www.macromedia.com/software/player_census/flashplayer/version_penetration.html.)
Flash Player 6 and 7 provide some remarkable capabilities to the
hundreds of millions of machines on which they are already installed.
With the user's consent, a Flash movie can capture
real-time audio and video from the machine's
microphone or web cam and stream it to Flash Communication Server MX.
(Here we use the term movie to refer to
.swf
files. We use the term
video
for visual content streamed
from the server.) The server can redistribute the streams to other
users who have the Flash Player. The resulting real-time
communications make it possible to develop a remarkable range of
compelling applications. The Flash authoring tool and the
Flash Communication Server MX can
be used to create:http://www.nellymoser.com)
formats, video encoded in the Flash Video format (FLV), and data encoded
using Macromedia's
Action Message Format
(AMF). AMF provides an efficient way to serialize/deserialize data so
that both primitive and complex ActionScript data can be transferred
between client and server without needing to manually encode or
decode the data. AMF is briefly described in Chapter 11, but for full details, see Flash
Remoting: The Definitive Guide
(O'Reilly).nc = new NetConnection( );
nc.connect("rtmp://echo.ryerson.ca/campusCameras/connector");
nc = new NetConnection( );
nc.onStatus = function (info) {
trace("The connection code is: " + info.code);
};
nc.connect("rtmp://echo.ryerson.ca/campusCameras/connector");
connector). If you've ever
developed network applications using other application programming
interfaces, you'll likely agree that creating a
network connection between Flash and FlashCom is ridiculously easy.
Chapter 3 goes into greater detail on the
NetConnection class and how to use
NetConnection objects.http://opensource.org for
information on open source code.http://www.macromedia.com/devnet/mx/flashcom/articles/firewalls_proxy.html
http://www.macromedia.com/software/flashcom
http://www.macromedia.com/cfusion/tdrc/index.cfm?product=flashcom
http://www.macromedia.com/support/flashcom/downloads_updaters.html
and install it. (Updaters are not normally added to the installation
files of the most recent release, so if an updater is available for
the most recent release, you should download and install it.)http://www.macromedia.com/support/flashcom/downloads_updaters.html
http://www.macromedia.com/software/flashcom/productinfo/systemreqs
idPool = ["guest_1", "guest_2", "guest_3", "guest_4"];
application.onAppStart = function ( ) {
users_so = SharedObject.get("users");
};
application.onConnect = function (client, name) {
if (idPool.length <= 0) {
application.rejectConnection(client, {msg:"Too many users."});
}
client.id = idPool.pop( );
application.acceptConnection(client);
client.call("setID", null, client.id);
users_so.setProperty(client.id, name);
};
application.onDisconnect = function (client) {
idPool.push(client.id);
users_so.setProperty(client.id, null);
};http://www.macromedia.com/software/flashcom/download/components
http://www.macromedia.com/support/flashcom/downloads_updaters.html
http://www.macromedia.com/cfusion/exchange/)
and install them with the Macromedia Extension Manager. You can also
create your own custom components as described in Chapter 13.http://chattyfig.figleaf.com for some of the
discussion.http://www.macromedia.com/devnet/mx/flash/articles/skinning_2004_print.html
threshold
property. Some component parameters
are configurable only via ActionScript, such as the
username
property of the Chat component. It is up
to the component developer to determine which properties of a
component are exposed in the Properties panel or the Component
Inspector panel. The communication components'
parameters can be exposed in the Component Definition dialog box
(available by right-clicking or Cmd-clicking the component symbol in
the Library). For any component written in ActionScript 2.0 (AS 2.0),
such as the Flash MX 2004 UI Components, parameters can also be
exposed by defining inspectable properties in its
load("components.asc");
list_mc instance, as shown in Figure 2-21.
av_1_mc instance. Name the new instance
av_2_mc.userColor_mc instance. Name the new instance
bandwidth_mc using the Properties panel. Your
Stage should now resemble Figure 2-24.
connect_mc instance on the Stage, and
double-click its Communication Components parameter in the Parameters
tab of the Properties panel. In the Values list, add the instance
names of the three additional communication
components—av_1_mc,
av_2_mcapp_nc = new NetConnection( );
app_nc.onStatus = function (info) {
trace("app_nc: info.code = " + info.code);
if (this.initLight == null) {
light_mc.connect(this);
this.initLight = true;
}
};
app_nc.connect("rtmp:/test_app");
light_mc when the onStatus( )
event handler is invoked. An internal property named
initLight
is used to track whether the
lobby_nc = new NetConnection( );
lobby_nc variable stores a
NetConnection object, which can be used to
attempt to connect to an application instance:if (lobby_nc.connect("rtmp:/testLobby", userName, password)) {
trace("Attempting connection...");
}
else {
trace("Can't attempt connection. Is the URI correct?");
}
false if it detects a malformed
URI; otherwise, it returns lobby_nc = new NetConnection( );
lobby_nc variable stores a
NetConnection object, which can be used to
attempt to connect to an application instance:if (lobby_nc.connect("rtmp:/testLobby", userName, password)) {
trace("Attempting connection...");
}
else {
trace("Can't attempt connection. Is the URI correct?");
}
false if it detects a malformed
URI; otherwise, it returns true, and Flash
attempts to connect to the server.rtmp or
rtmpt followed by a colon; otherwise, the
connect( ) method may return
true and then fail.uri property of the
NetConnection object.rtmp[t]://host[:port]/applicationName[/instanceName]
info object passed to the onStatus(
) method will have a level value of
"status" and a
code value of
"NetConnection.Connect.Closed".
This will happen if the network goes down, the server disconnects the
client, the server stops, or the connection is closed using
NetConnection.close( ). It is also possible that
the level value will be
"error" and the
code value
"NetConnection.Connect.AppShutdown".
The following sections discuss how to deal with various connection
status changes.room1. In this case, the main timeline of the
movie would require separate Login,
Lobby, and ChatRoom frames as
illustrated in Figure 3-2.
Lobby
frames, and a Lobby button would be placed within the
ChatRoom frames. Example 3-4
shows the onChat( ) function that would be
called when the Chat button is clicked.function doChat (btn) {
// Don't process the next close message.
lobbyChat_nc.handleCloseEvents = false;
// Close the connection to the lobby.
lobbyChat_nc.close( );
// Set the