This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
30
|
Chapter 1: Introducing the Flash Communication Server
represents the user, we can show the name the user selected when she logged in by
setting the text of the
nameInput TextInput component inside the movie clip:
mc.nameInput.text = users_so.data[id];
Unlike the server-side code that used users_so.setProperty( ) and users_so.getProp-
erty( ) to set and get values in a shared object slot, in the client a special
data object is
available to read and write slot values. For example, to get or set the
guest_2 slot of
the shared object, use the expression:
users_so.data["guest_2"].
Because the server-side code changes a slot each time a user connects, the client will
receive notification that a slot has changed when other remote users connect as well
as when it connects. However, we want to play only the streams of remote users
because there is no point in wasting bandwidth to play the local user’s own stream.
Fortunately, the setID( ) method was called before the shared object was set up and
connected, so we already know the local user’s ID. If
id is different from the value in
the
myID variable, id represents a remote user and we can safely play it. To play it, the
code creates a new NetStream object and attaches it as a dynamic property of the
movie clip:
var ns = new NetStream(nc);
mc.video.attachVideo(ns);
ns.play(id);
mc.ns = ns;
If a remote user disconnects, the NetStream object playing her stream can be safely
closed, her video cleared, and the
nameInput field set to an empty string:
case "delete":
var id = info.name;
var mc = _root[id];
mc.ns.close( );
mc.nameInput.text = "";
mc.video.clear( );
break;
Hello Video! Summary
If you’ve read through the code and commentary on the helloVideo application,
you’ve seen most of the communication classes working together to create a very
simple video conference application. And, while there is a lot more we can do with
Flash and FlashCom, you’ve already seen many of the essential techniques for build-
ing a communication application.
Conclusion
While writing this book, I met online with the other authors to discuss our project. I
used some of the sample applications I wrote for the book and another Macromedia
application built on top of Flash and FlashCom: Breeze Live. One of the earliest
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Conclusion
|
31
conferences I had was with Robert Reinhardt. I was at home in Toronto, on eastern
standard time, and he was in Los Angeles on Pacific time. It was dark in Toronto and
the sun was about to start setting in L.A. Aside from the immediacy of our conversa-
tion—something more akin to being in the same room than being on the phone or
using text messaging—there was something compelling about seeing the light gradu-
ally change on the other side of the continent as we spoke. In later conferences with
Giacomo Guilizzoni, I was impressed with how helpful it was to be able to share
code and make notes that we could both see and edit while we discussed what parts
of this book each of us should work on. Communication applications that include
live video, audio, and data make collaboration at a distance more immediate and
effective. Flash and FlashCom together provide a platform that can be used to build
a wide range of compelling communication applications. Whether you need to build
a shared simulation to enhance an online course or a simple video conference, text
chat, or video-on-demand application, you’ll find a rich toolbox of classes and com-
ponents to create it described in detail in the chapters that follow.

Get Programming Flash Communication Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.