This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
40
|
Chapter 2: Communication Components
Nested Flash UI components
The AudioConference component uses four Flash MX UI components: CheckBox,
ListBox, PushButton, and ScrollBar.
Component process overview
When the AudioConference component loads into a Flash movie, the component
uses an existing NetConnection object (which can be provided by a SimpleConnect
component) to create or connect to a non-persistent RSO named
FCAudioConference.
audio
.
Whenever a communication component instance uses an RSO, any
changes made to the RSO are broadcast to all connected users (or par-
ticipants) of the same application instance. The communication com-
ponents do not prohibit or exclude users of the same application
instance from sharing data with one another.
This RSO keeps track of each connected user. When a user clicks the Talk button,
the component attaches his microphone output to a NetStream instance and sets a
property within the RSO to
true. This property’s name is based on the user’s ID,
which is provided by the server-side component framework. When other clients
receive this updated value in the SharedObject.onSync( ) handler, the audio stream
from the other user is played. When the user releases the Talk button, the compo-
nent sets the RSO’s property to
false, and the user’s microphone output detaches
from the stream.
AVPresence
The AVPresence component, by far one of the more popular communication compo-
nents, allows a user connected to a FlashCom application to send an audio and/or
video stream to other users. An AVPresence instance presents a masked area of the
user’s camera output as shown in Figure 2-3. The user can selectively mute the audio
and/or video output. The component displays the microphone’s activity level along
the right border.
Figure 2-2. The AudioConference component
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Summary of Communication Components
|
41
One of the special attributes of the AVPresence component is that it can be used to
either send a user’s audio/video stream or receive another user’s audio/video stream.
The AVPresence instance name establishes a unique identifier within the FlashCom
application. If you place an AVPresence component instance named
user_1_mc
within a Flash movie (a .swf file), anyone who loads the Flash movie and connects to
the FlashCom application can engage the
user_1_mc instance to begin streaming
audio/video. Once a user has started to publish a stream with the
user_1_mc instance,
any other users who have loaded the same Flash movie will start to see that user’s
stream in their instance of
user_1_mc. If you want to provide multiple users simulta-
neous access to the functionality of the AVPresence component, you will need to cre-
ate a unique instance of the AVPresence component for each user.
Once a user relinquishes control of an AVPresence instance, another user can use
that same instance to start publishing her audio/video stream.
In order for a user to gain access to the AVPresence component, the following events
must occur:
1. The AVPresence component must be connected to the active NetConnection
instance of the FlashCom application. This connection can be created with the
SimpleConnect component (discussed later in this chapter) or with custom
ActionScript.
2. The user must specify a preferred login name in the SimpleConnect component,
or AVPresence.setUsername( ) must be invoked with a string value. If a user’s
name is not set, the AVPresence instance displays the text “Login to Send Audio/
Video.”
3. Once a username has been established, the user can click the Send Audio/Video
link within the AVPresence instance to begin publishing an audio/video stream
to the FlashCom application. Any other user viewing the same AVPresence
instance will receive the streaming audio and video.
4. To stop sending an audio/video stream, the user must roll over the instance’s
video area and click the button depicting a red X in a circle, in the lower-left cor-
ner of the component as seen in Figure 2-3. Once the stream stops publishing,
another user can begin using the same AVPresence instance.
Figure 2-3. The AVPresence component

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.