macromedia™®Getting Started withFlash Communication ServerMacromedia Flash™ Communication Server MX
Chapter 210System requirements for the Flash PlayerBecause the client side of a Flash Communication Server application runs in Flash Player 6, you (an
Chapter 122To test your sample application:1 Choose File > Publish Settings, select Flash and HTML, click Publish, and then click OK.2 Choose Contr
23CHAPTER 2About Flash Communication ServerApplicationsWith a few lines of code, your Macromedia Flash MX application (SWF) can communicate with anoth
Chapter 224Passing data between clientsIn Chapter 1, the sample connection application (see “Writing your first application” on page 19) connected to
About Flash Communication Server Applications 25Tracking client informationYou can use server-side ActionScript to collect and display information reg
Chapter 226While you can use the Flash Communication Server server-side scripting language to implement transactions, either internally or by communic
About Flash Communication Server Applications 27When the user runs your Flash SWF file and the SWF file connects to the server, the server loads the a
Chapter 228After a successful connection, the client makes a call on the connection. If the client needs a result returned, the client provides a call
About Flash Communication Server Applications 29Finally, here’s an overview of the remote shared object flow. A Flash client movie subscribes to a rem
Chapter 230When designing your application, note the functionality used on both the client and the server. For a description of how to use the client-
Sample Applications 31CHAPTER 3Sample ApplicationsThis chapter provides examples of a number of Macromedia Flash Communication Server MX programming t
Installation and Workflow 11If you choose Production Install, you can specify both the location of your client-side application files (SWFs and HTMLs)
Chapter 3 32Specifying publishing formats. You should have Flash MX configured to publish both SWF and HTML files. To specify formats to be created du
Sample Applications 33Re-creating the sampleThe doc_record.fla file provides the ActionScript for getting a camera, attaching it to a Video object, cr
Chapter 3 344 In the initStreams function, make a connection to the server. Create the output stream for sending the video data to the server, and the
Sample Applications 356 Create the event handler for the Play button that plays the stream recorded on the server.function doPlay() {in_ns.play("
Chapter 3 362 Open a connection to the server.// Open connection to serverclient_nc = new NetConnection();client_nc.connect("rtmp:/doc_text/room_
Sample Applications 37Sample 3: Shared BallThis sample allows users to move a ball around the screen and to watch while other participants move the ba
Chapter 3 385 When you get a shared object, make sure you connect it to the NetConnection object.// Connect to the shared objectball_so.connect(client
Sample Applications 39To create the user interface for this sample:1 In the Flash MX authoring environment, select File > New to open a new file.2
Chapter 3 404 Create the event handler for the Connect button. If the user selected the button when the label was Connect, then connect to the server.
Sample Applications 41To write the server-side ActionScript for this sample:1 Create a new file using your server-side ActionScript editor, and write
Chapter 21212 Click Finish. The Flash Communication Server service starts up. The server runs as a service, which means it runs in the background and
Chapter 3 42About the sampleIn a chat room, you want to view current users dynamically. When users log in to a room, the list should be updated; when
Sample Applications 433 Provide a value for the maximum scrolling of the History text box component.// Set maximum scrollHistory.maxscroll = 1000;4Pre
Chapter 3 449 In the same doConnect function, create the onSync method to handle the change in users. // When the list of users_so is updated, refresh
Sample Applications 4513 Create the setHistory function that the server calls to update the text in the History dynamic text box.// Update the History
Chapter 3 463 Write the event handler onDisconnect to clean up.application.onDisconnect = function(client){trace("disconnect: " + client.nam
Sample Applications 476 To add a Video object to your library, open the Library panel (Window > Library) and add an embedded Video object by select
Chapter 3 486 Remember to connect the shared object to the NetConnection object.// Connect to the shared objectrec_so.connect(client_nc);7Create an ev
Sample Applications 499 Create the event handler for the Play button. If the user selects Play, update the button label, create an input stream, and p
Chapter 3 50
51CHAPTER 4Application Development Tips and TricksThis chapter is designed to supplement, not replace, application development and best practices reco
Installation and Workflow 13To install the authoring components:1 Locate the FlashComInstaller file.This file is on your installation CD, or you may h
Chapter 452For example, the code below shows how you could create a network connection on the client side, and then make a call to it from the server
Application Development Tips and Tricks 53On the server sideOn the server side, you must implement slightly different code, using global instead of _r
Chapter 454Managing bandwidthYou can control the amount of data the server sends to each client by providing an approximate bandwidth capacity. There
Application Development Tips and Tricks 55Note: If you are using speakers instead of a headset, you may want to comment out the call to Microphone.get
Chapter 456cam.setKeyFrameInterval(5);client_mic.setRate(11);// For demonstration purposes, change size of screenOutput_mc._height = 130;Output_mc._wi
Application Development Tips and Tricks 57Writing double-byte applicationsIf you are using server-side ActionScript in a development environment or la
Chapter 458Because shared object and stream names are strings, and both follow the same rules of URI-encoded data, you can define access based on the
Application Development Tips and Tricks 59In addition to the specific onStatus methods provided for the objects listed above, Flash MX also provides a
Chapter 460Debugging NetConnection.Connect.FailedIf a NetConnection.connect command returns an information object with a code value of NetConnection.C
Application Development Tips and Tricks 613 From the options menu in the Library panel (Window > Library), select New Symbol, and give it the name
Chapter 214How Flash Communication Server worksThe Flash Communication Server platform comprises the server that provides the means of communication a
Chapter 4626 Copy and paste the following code to the Actions panel for the first frame of the movie:stop();var userAnswer = false;function doRecord()
Application Development Tips and Tricks 63// If the user selects the No button, they// do not want to record. So, set userAnswer// to false, unload th
Chapter 464In addition, words that are used by ActionScript should never be used as names. Also avoid using variable names of common programming const
Application Development Tips and Tricks 65• // :TRICKY:Notifies developers that the subsequent code has a lot of interactions. Also advises developers
Chapter 466This code outputs:77012345In this case, the counter variable on the main Timeline is overwritten by the counter variable within the functio
Application Development Tips and Tricks 67The following example demonstrates a correct technique for creating an object, but should be used only when
Chapter 468Recorded stream filesWhen you use methods that record audio, video, or data streams (for example, NetStream.publish), Flash Communication S
Application Development Tips and Tricks 69Persistent local shared objectsYou create persistent local shared objects by using the client-side SharedObj
Chapter 470Snapshots and thumbnailsThis section compares the techniques for grabbing single frames of video as pictures to use within your application
Application Development Tips and Tricks 71The following client-side ActionScript code in doc_snapshot.fla connects to the server and plays camera outp
Installation and Workflow 15Client connections to Flash Communication Server use the Real-Time Messaging Protocol (RTMP), which, unlike HTTP, provides
Chapter 472} else {// Stop publishing recorded streamout_ns.publish(false);// Close the stream so that we can use the same to publish againout_ns.clos
Application Development Tips and Tricks 73In the following client-side ActionScript code in doc_thumbnails.fla, the server records the incoming stream
Chapter 474out_ns.publish("myRecording", "record");Record_btn.setLabel("Stop");recState = 1;} else {out_ns.publish(false
Application Development Tips and Tricks 75Application objectThis section includes recommendations to help you optimize your use of the server-side App
Chapter 476Application.onDisconnectThe server calls the application.onDisconnect method when the NetConnection is closed. You cannot use client.call o
Application Development Tips and Tricks 77Using one camera in multiple applicationsMultiple applications (SWFs) can use the same camera at the same ti
Chapter 478Second, there is a bit of JavaScript you can use in your HTML page to avoid the security problem. Assuming the movie uses a fully qualified
Application Development Tips and Tricks 79Getting the stream time length in ActionScriptIf you are buffering your streams, you can use the NetStream.b
Chapter 480NetStream.timeAlthough it is not explicitly stated in the Client-Side Communication ActionScript Dictionary, the NetStream.time property re
Application Development Tips and Tricks 81If you are having problems understanding how your shared object is behaving, it helps to put some debug code
Chapter 216The NetConnection object tells the Flash Player to connect to an application on the server. You can use NetConnection objects to create pow
Chapter 482Assign an owner A more complex strategy is to define a single client as the owner of a property in a shared object for a limited period of
Application Development Tips and Tricks 83Stream objectIf you want to delete the FLV and IDX files associated with a recorded stream, you must use ser
Chapter 484Understanding frame ratesIf you embed an FLV file in a movie in a static SWF file, its frame rate will be the same as the frame’s playback
85CHAPTER 5Application Server ConnectivityThis chapter explains how to use Macromedia Flash Remoting services to add application server connectivity t
Chapter 586You’ll place the FLA and ASC files in your application directory, and place in that same directory the netservices.asc file that enables Ne
Application Server Connectivity 872 Create the event handler for the Run_btn button. Notice the call to runTests. This invokes the function you’ll def
Chapter 5883 In the onConnect function, accept the client’s connection.application.onConnect = function (clientObj) {trace("***** on connect"
Application Server Connectivity 898 For each test, receive the result, result. Then call the client-defined function postResults and pass the client t
Chapter 5904 Create the getArray method that the Flash Communication Server will invoke.<cffunction name="getArray" output="false&qu
Application Server Connectivity 91To write the client-side ActionScript for this sample:1 Add the following debug code to trace all the status informa
Installation and Workflow 17Developer workflowIf you’re a developer, you can create a Flash Communication Server application that has a client compone
Chapter 5923 In the onConnect function, accept the client’s connection.application.onConnect = function (clientObj) {trace("***** on connect"
Application Server Connectivity 93Sample 3: RecordsetOnce you have easy access to a database, you add data storage and retrieval to your Flash Communi
Chapter 5943 In the same method, assign a variable name, recstr, for the data coming from the call to getRecordString and populate the list box with t
Application Server Connectivity 953 Create a global object to hold the recordset.// An object to hold your service and recordsetgFoo = {};4Get a refer
Chapter 596
Flash Communication Server Management Tools 97APPENDIXFlash Communication ServerManagement ToolsAs an application developer, one of your most import
Appendix 98Connecting the App inspector to a serverWhen you open the App inspector, you use the log-on screen to connect as an administrator to the
Flash Communication Server Management Tools 99The Application Instance panelAfter you have connected to the server, the App inspector displays a pan
Appendix 100The Live Log panelThe Live Log panel displays the log messages that are generated by the selected application instance on the server and
Flash Communication Server Management Tools 101The Streams panelThe Streams panel displays information about the streams associated with the selecte
Chapter 218The following resources will help you develop Flash Communication Server applications.To begin To get started in the development process, b
Appendix 102The Shared Objects panelThis panel shows information about the shared objects used by the application instance (and resident on the serv
Flash Communication Server Management Tools 103This panel lets you perform the following tasks:• To return to the list of currently running applicat
Appendix 104Messages per Sec (In/Out) indicates the average number of messages (video frames from cameras, audio packets, and command messages) per
Flash Communication Server Management Tools 105Using the NetConnection DebuggerThe NetConnection Debugger provides Flash MX developers with a tool t
Appendix 106Events shows a list of individual debug events. Each debug event contains an icon that represents the debug event source, the type of de
Flash Communication Server Management Tools 107Operator lets you select the comparison criterion that must be met for an event to appear in the Even
Appendix 108Request Limits controls the maximum number of events that are displayed from an application server per transaction, and the maximum numb
109INDEXSymbols# Active 103# Properties 102# Users Connected 102#include 52#include "NetDebug.as" 32, 105AAccepted (Total) 103ACL (ac
Index110change, and SharedObject.onSync 80clear, and SharedObject.onSync 80Client ID 101client information, tracking 25Client object 12and client
Index 111LLaunch Time 103Live Log panel 100local shared object. See shared objectslocal variables and var 65localhost, and NetConnection.connect 1
Installation and Workflow 19Administrator workflowIf you’re an administrator, you’ll use the Administration Console to configure Flash Communication S
Index112Ppassing data between clients 24persistence, and shared objects 68Player Settings panel 53Player, latest version 17portability and applica
Index 113Subscribed Events 107Summary panel 106System.onStatus 59System.showSettings 53Tthumbnails 70, 72tips and tricks 83Application object
macromedia™®Client-Side CommunicationActionScript DictionaryMacromedia Flash™ Communication Server MX
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
3CONTENTSClient-Side Communication ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Camera (object). . . . . . . . . . . . . .
Contents4Microphone.name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Microphone.names .
Contents 5System (object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99System.showS
Contents6
7Client-Side Communication ActionScriptThis document is designed to be used in conjunction with the information in the online Flash ActionScript Dicti
8gain Microphone.gainget Camera.get, Microphone.getgetLocal SharedObject.getLocalgetRemote SharedObject.getRemotegetSize SharedObject.getSizeheight Ca
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
Chapter 220
Client-Side Communication ActionScript 9Camera (object)Availability• Flash Player 6.• Flash Communication Server MX (not required).The Camera object l
10Method summary for the Camera objectProperty summary for the Camera objectMethod DescriptionCamera.get Returns a default or specified Camera object,
Client-Side Communication ActionScript 11Event handler summary for the Camera objectConstructor for the Camera objectSee Camera.get.Camera.activityLev
12ExampleThe following example loads another movie if the camera’s bandwidth is 32 kilobytes or greater.if(myCam.bandwidth >= 32768){loadMovie(&quo
Client-Side Communication ActionScript 13ExampleThe following example sets the fps rate of the active camera, myCam.fps, to the value provided by the
14When a movie tries to access the camera returned by Camera.get—for example, when you issue NetStream.attachVideo or Video.attachVideo—the Flash Play
Client-Side Communication ActionScript 15ExampleThe following example captures and displays video locally within a Video object named myVid on the Sta
16Camera.keyFrameIntervalAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamera.keyFrameIntervalDescriptionRead
Client-Side Communication ActionScript 17Camera.motionLevelAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCame
18Camera.mutedAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamera.mutedDescriptionRead-only property; a Bool
21GLOSSARYFlash Communication Server Termsapplication server Software that helps a web server process web pages that contain server-side scripts or ta
Client-Side Communication ActionScript 19ExampleThe following example displays the name of the default camera in the Output window. In Windows, this n
20Camera.onActivityAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamera.onActivity = function(activity) {// Y
Client-Side Communication ActionScript 21Camera.onStatusAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamera.
22Camera.qualityAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamera.qualityDescriptionRead-only property; an
Client-Side Communication ActionScript 23To determine how to set a value for keyframeInterval, consider both bandwidth use and video playback accessib
24See alsoCamera.loopback, Camera.setQualityCamera.setModeAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveCamer
Client-Side Communication ActionScript 25ExampleThe following example sets the width, height, and fps based on the user’s input if the user clicks the
26Motion sensitivity values correspond directly to activity values. Complete lack of motion is an activity value of 0. Constant motion is an activity
Client-Side Communication ActionScript 27ReturnsNothing. DescriptionMethod; sets the maximum amount of bandwidth per second or the required picture qu
28ExampleThe following line of code updates a text box in the user interface with the current width value.myTextField.text=myCam.width;See also the ex
macromedia™®Managing FlashCommunication ServerMacromedia Flash™ Communication Server MX
Client-Side Communication ActionScript 29Method summary for the LocalConnection objectEvent handler summary for the LocalConnection objectConstructor
30See alsoLocalConnection.connect, LocalConnection.sendLocalConnection.allowDomain Availability• Flash Player 6.• Flash Communication Server MX (not r
Client-Side Communication ActionScript 31In the following example, the receiving movie accepts commands only from movies located in thisDomain.com or
32ParametersconnectionName A string that corresponds to the connection name specified in the LocalConnection.send command that wants to communicate wi
Client-Side Communication ActionScript 33Movie 1 contains the following code attached to a button labeled PushMe. When you push the button, you see “T
34The most common use of this command is to include the domain name of the sending LocalConnection object as a parameter to the method you plan to inv
Client-Side Communication ActionScript 35• The aResult method (line 54) displays the value returned by aSum (579). // The receiving movie at http://ww
36DescriptionEvent handler; invoked after a sending LocalConnection object tries to send a command to a receiving LocalConnection object. If you want
Client-Side Communication ActionScript 37ParametersconnectionName A string that corresponds to the connection name specified in the LocalConnection.co
38See alsoLocalConnection.allowDomain, LocalConnection.connect, LocalConnection.domain, LocalConnection.onStatusMicrophone (object)Availability• Flash
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
Client-Side Communication ActionScript 39Event handler summary for the Microphone objectConstructor for the Microphone objectSee Microphone.get. Micro
40Microphone.gainAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveMicrophone.gainDescriptionRead-only property;
Client-Side Communication ActionScript 41Microphone.getAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageMicrophone.get
42When a movie tries to access the microphone returned by Microphone.get—for example, when you issue NetStream.attachAudio or MovieClip.attachAudio—th
Client-Side Communication ActionScript 43ExampleThe following example lets the user specify the default microphone, then captures audio and plays it b
44ExampleIn the following example, when the user clicks the button, Flash publishes and plays a live stream if the microphone is not muted.on (press)
Client-Side Communication ActionScript 45Microphone.namesAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageMicrophone.n
46Parametersactivity A Boolean value set to true when the microphone starts detecting sound, false when it stops.ReturnsNothing.DescriptionEvent handl
Client-Side Communication ActionScript 47When a movie tries to access the microphone, the Flash Player displays a Privacy dialog box that lets the use
48Microphone.setGainAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveMicrophone.setGain(gain)Parametersgain An i
3CONTENTSINTRODUCTIONManaging Flash Communication Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Intended audience. . . . . . . .
Client-Side Communication ActionScript 49ReturnsNothing.DescriptionMethod; sets the rate, in kHz, at which the microphone should capture sound.Example
50Silence values correspond directly to activity values. Complete silence is an activity value of 0. Constant loud noise (as loud as can be registered
Client-Side Communication ActionScript 51DescriptionMethod; specifies whether to use the echo suppression feature of the audio codec. The default valu
52Microphone.silenceTimeoutAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsageactiveMicrophone.silenceTimeoutDescription
Client-Side Communication ActionScript 53MovieClip (object) This object is discussed in detail in the online Flash ActionScript Dictionary in the Flas
54NetConnection (object)Availability• Flash Player 6.Flash Communication Server MX.• The NetConnection object manages a bidirectional connection betwe
Client-Side Communication ActionScript 55DescriptionConstructor; creates an object that can be used to connect the Flash Player to the Flash Communica
56DescriptionMethod; invokes a command or method on the server. You must create a server-side function to define this method. This method is also used
Client-Side Communication ActionScript 57DescriptionMethod; closes the connection with the server and invokes NetConnection.onStatus with a code prope
58For example, the following URIs are formatted correctly:• rtmp://www.myCompany.com/myMainDirectory/groupChatApp/HelpDesk• rtmp:/sharedWhiteboardApp/
Contents4
Client-Side Communication ActionScript 59If your connection fails, make sure you have met all the requirements for connecting successfully:• You are s
60Understanding file naming and domains used with this methodIf an HTML page containing a movie is accessed differently (with regards to domain names)
Client-Side Communication ActionScript 61NetConnection.isConnectedAvailability• Flash Player 6.• Flash Communication Server MX.UsagemyConnection.isCon
62ExampleThe following example writes data about the connection to a log file.reconnection.onStatus = function(info){_root.log += "Recording stre
Client-Side Communication ActionScript 63The following steps summarize the sequence of actions required for publishing real-time audio and video using
64Method summary for the NetStream objectProperty summary for the NetStream objectEvent handler summary for the NetStream objectConstructor for the Ne
Client-Side Communication ActionScript 65ParametersmyRTMPConnection A NetConnection object that is using the Real-Time Messaging Protocol (RTMP) to co
66Parameterssource The source of the audio to be transmitted. Valid values are a Microphone object andnull.ReturnsNothing.DescriptionMethod; specifies
Client-Side Communication ActionScript 67ReturnsNothing.DescriptionMethod; starts capturing video from the specified source, or stops capturing if sou
68ExampleThe following function publishes a stream containing the camera output.function pubLive(){// Create a new source stream.srcStream = new NetSt
5INTRODUCTIONManaging Flash Communication ServerMacromedia Flash Communication Server MX enables one-to-one, one-to-many, many-to-one, and many-to-man
Client-Side Communication ActionScript 69DescriptionProperty; the number of seconds assigned to the buffer by NetStream.setBufferTime. The default val
70NetStream.currentFpsAvailability• Flash Player 6.• Flash Communication Server MX.UsagemyStream.currentFpsDescriptionRead-only property; the number o
Client-Side Communication ActionScript 71ReturnsNothing.DescriptionMethod; pauses or resumes playback of a stream. This method is available only to cl
72NetStream.playAvailability• Flash Player 6.• Flash Communication Server MX.Usagemystream.play(whatToPlay | false [,start [, length [, flushPlaylists
Client-Side Communication ActionScript 73DescriptionMethod; feeds streaming audio, video, and text messages being published on the Flash Communication
74Example 2:// To play and switch between live and recorded streams:// Suppose we have two live streams, live1 and live2, // and three recorded stream
Client-Side Communication ActionScript 75• If you pass "append" for howToPublish, Flash publishes and records live data, appending the recor
76ExampleThe following example shows how to publish and record a video, and then play it back.connection = new NetConnection();connection.connect(&quo
Client-Side Communication ActionScript 77Parametersreceive A Boolean value that specifies whether incoming video plays on the specified stream (true)
78ParametersnumberOfSeconds The number of seconds to move forward or backward in a recorded stream or playlist. • To return to the beginning of the st
Introduction6About the Flash Communication Server documentationAll Flash Communication Server documents are available in PDF format (viewable and prin
Client-Side Communication ActionScript 79p1, ...,pN Optional parameters that can be of any type. They are serialized and sent over the connection, and
80DescriptionMethod; behavior depends on whether this method is called on a publishing or a subscribing stream.• For a publishing stream, this method
Client-Side Communication ActionScript 81ExampleThe following example shows how this value increments for a publishing stream.myStream.publish("s
82The following examples show a few ways shared objects are called within ActionScript programs. Note that in order to create a remote shared object,
Client-Side Communication ActionScript 83Compare this data structure to a shared object with the same attributes, but with a flat design that occupies
84By default, Flash can save locally persistent remote shared objects up to 100 K in size. When you try to save a larger object, the Flash Player disp
Client-Side Communication ActionScript 85Additionally, if the user selects a value that is less than the amount of disk space currently being used for
86Method summary for the SharedObject objectProperty summary for the SharedObject objectEvent handler summary for the SharedObject objectConstructor f
Client-Side Communication ActionScript 87SharedObject.closeAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyRemoteSh
88ExampleThe following example connects to a shared object and initializes it.function getMaster(){ trace("getMaster called");master = Share
7CHAPTER 1Installing Flash Communication ServerInstalling Macromedia Flash Communication Server MX is a simple process. This chapter describes the ins
Client-Side Communication ActionScript 89To create “private” values for a shared object—values that are available only to the client instance while th
90For example, if you expect a shared object to grow to a maximum size of 500 bytes, even though it may start out much smaller, pass 500 for minimumDi
Client-Side Communication ActionScript 91See alsoLocal disk space considerations, SharedObject.closeSharedObject.getLocalAvailability• Flash Player 6.
92ExampleThe following example saves the last frame a user entered to a local shared object kookie. // Get the kookieso = sharedobject.getlocal("
Client-Side Communication ActionScript 93ReturnsA reference to an object that can be shared across multiple clients. If Flash can’t create or find the
94Understanding naming conventions for remote shared objects. To avoid name collisions, Flash looks at the location of the movie that is creating the
Client-Side Communication ActionScript 95SharedObject.getSizeAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyLocalO
96SharedObject.onSyncAvailability• Flash Player 6.• Flash Communication Server MX.UsagemyRemoteSharedObject.onSync = function(objArray){// Your code h
Client-Side Communication ActionScript 97To minimize network traffic, this method is not called when a client “changes” a property to the same value i
98DescriptionMethod; broadcasts a message to all clients connected to myRemoteSharedObject, including the client that sent the message. To process and
Chapter 18To install Flash Communication Server:1 Locate the FlashComInstaller.exe file.This file is on your installation CD, or you may have download
Client-Side Communication ActionScript 99Regardless of the value you pass for updatesPerSecond, changes are not sent to the server until SharedObject.
100For example, if your application requires the use of a camera, you can inform the user that they must choose “Allow” in the Privacy Settings panel,
Client-Side Communication ActionScript 101Video.attachVideoAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyVideoObj
102Video.clearAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyVideoObject.clear()ParametersNone.ReturnsNothing.Desc
Client-Side Communication ActionScript 103Video.heightAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyVideoObject.h
104Video.widthAvailability• Flash Player 6.• Flash Communication Server MX (not required).UsagemyVideoObject.widthDescriptionRead-only property; an in
Client-Side Information Objects 105APPENDIXClient-Side Information ObjectsThe Camera, Microphone, LocalConnection, NetConnection, NetStream, and Share
Appendix106The following tables show the default properties of each information object and the circumstances under which onStatus is invoked with each
Client-Side Information Objects 107NetConnection information objectsThe following events notify you when certain NetConnection activities occur.NetStr
Appendix108NetStream.Play.Reset Status The playlist has reset (pending play commands have been flushed).NetStream.Play.Start Status Playback has start
3CONTENTSCHAPTER 1Introducing Flash Communication Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Flash Communication Server edition
Installing Flash Communication Server 9About the installed filesWhen the server has been installed, you’ll find several other files in the installatio
Client-Side Information Objects 109SharedObject information objectsThe following events notify you when certain SharedObject activities occur.Code pro
macromedia™®Server-Side CommunicationActionScript DictionaryMacromedia Flash™ Communication Server MX
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
3CONTENTSServer-Side Communication ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Using server-side ActionScript. . . . . . .
Contents4NetConnection.isConnected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38NetConnection.onStatus
Server-Side Communication ActionScript 5Server-Side Communication ActionScriptServer-Side Communication ActionScript is a scripting language on the se
6To install and test the server-side ActionScript file, do the following: 1 Locate the flashcom application directory.During installation, you can cho
Server-Side Communication ActionScript 7Naming applications Flash Communication Server application names must follow the Uniform Resource Identifier (
8clearInterval clearIntervalclearSharedObject Application.clearSharedObjectsclearStreams Application.clearStreamsClient Client (object)clients Applica
Server-Side Communication ActionScript 9Application (object)The Application object contains information about a Flash Communication Server application
Chapter 110Installing Flash authoring components on the Macintosh To install the Communication App inspector, NetConnection Debugger, and related help
10Method summary for the Application objectProperty summary for the Application object Event handler summary for the Application objectApplication.acc
Server-Side Communication ActionScript 11DescriptionMethod; accepts the connection call from a client to the server. The application.onConnect event h
12The following are possible values for the soPath parameter:• / clears all local and persistent shared objects associated with the instance.• /foo/ba
Server-Side Communication ActionScript 13The following are possible values for the streamPath parameter:• / clears all recorded streams associated wit
14ExampleThis example uses a for loop to iterate through each member of the application.clients array and calls the method serverUpdate on each client
Server-Side Communication ActionScript 15ExampleThe following example checks the name property against a specific string before it executes some code:
16DescriptionEvent handler; invoked when the application is about to be unloaded by the server. You can define a function that executes when the event
Server-Side Communication ActionScript 17p1 ..., pN Optional parameters passed to the application.onConnect method. These parameters are passed from t
18DescriptionEvent handler; invoked on the server side when NetConnection.connect is called from the client side and a client attempts to connect to a
Server-Side Communication ActionScript 19Usageapplication.onDisconnect = function (clientObj){// insert code here};ParametersclientObj A client discon
11CHAPTER 2Managing the ServerAs a Flash Communication Server administrator, you’ll need to perform several administrative tasks after the server is i
20ExampleThe following example defines a function that sends a trace statement whenever the application.onStatus method is invoked. You can also defin
Server-Side Communication ActionScript 21If you register a class that has its prototype set to another class, you must set the prototype constructor b
22ParametersmethodName The name of a method. All requests to execute methodName for this application instance are forwarded to the proxyConnection obj
Server-Side Communication ActionScript 23ReturnsNothing.DescriptionMethod; rejects the connection call from a client to the server. The application.on
24clearIntervalAvailabilityFlash Communication Server MX.UsageclearInterval(intervalID)ParametersintervalID A unique ID returned by a previous call to
Server-Side Communication ActionScript 25If all instances of the Client object (each client in an application) require the same methods or properties,
26The methods are available to any instance, so within application.onConnect, which is passed a clientObj argument, you can write the following code:a
Server-Side Communication ActionScript 27ExampleThe following example checks the agent property against the string "WIN" and executes differ
28The following server-side script uses the Client.call method inside the application.onConnect handler to call the random method that was defined on
Server-Side Communication ActionScript 29The sum method can then be called from NetConnection.call on the Flash client side, as shown in the following
Chapter 212An optional Application.xml file in the application’s directory in the flashcom application directory. If present, this file provides speci
30ReturnsAn integer indicating bytes per second.DescriptionMethod; returns the maximum bandwidth that the client or the server can use for this connec
Server-Side Communication ActionScript 31By default, all clients have full read access, and the readAccess property is set to slash (/). To give a cli
32ParameterspropName The name of an undefined property.ReturnsThe value of the undefined property, which is specified by the propName parameter.Descri
Server-Side Communication ActionScript 33Client.writeAccessAvailabilityFlash Communication Server MX.UsageClient.writeAccessDescriptionProperty; provi
34Note: For security reasons, your server-side applications directory, which contains ASC files, audio/video FLV files, and ActionScript FLA source fi
Server-Side Communication ActionScript 35Method summary for the NetConnection object Property summary for the NetConnection object Event handler summa
36Parameters name A string that identifies the header and the ActionScript object data associated with it.mustUnderstand A Boolean value; true indicat
Server-Side Communication ActionScript 37DescriptionMethod; invokes a command or method on a Flash Communication Server or an application server to wh
38ExampleThe following code closes the NetConnection instance myNetConn:myNetConn.close();NetConnection.connectAvailabilityFlash Communication Server
Server-Side Communication ActionScript 39UsagemyNetConnection.isConnectedDescriptionProperty (read-only); a Boolean value that indicates whether a con
Managing the Server 13When you install the server, the default flashcom application directory includes sample applications that are provided to illust
40ExampleThis example defines a function for the onStatus handler that outputs messages to indicate whether the NetConnection was successful:nc = new
Server-Side Communication ActionScript 41DescriptionMethod (global); continually calls a function or method at a specified time interval until the cle
42Every shared object is identified by a unique name and contains a list of name-value pairs, called properties, just like any other ActionScript obje
Server-Side Communication ActionScript 43Method summary for the SharedObject object Property summary for the SharedObject object Event summary for the
44ParametersNone.ReturnsReturns true if successful; false otherwise. DescriptionMethod; deletes all properties and sends a “clear” event to all client
Server-Side Communication ActionScript 45SharedObject.flushAvailabilityFlash Communication Server MX.UsageSharedObject.flush()ParametersNone.ReturnsA
46DescriptionStatic method; returns a reference to a shared object instance. To perform any operation on a shared object, the server-side script must
Server-Side Communication ActionScript 47ExampleThis example creates a shared object named foo inside the function onProcessCmd. The function is passe
48SharedObject.getPropertyNamesAvailabilityFlash Communication Server MX.UsagemySharedObject.getPropertyNames()Parameters None.ReturnsAn array contain
Server-Side Communication ActionScript 49The this keyword used in the body of the function is set to the shared object instance returned by SharedObje
Chapter 214Once you have specified the directory where you’ll store your application directories, you must create a directory inside it for each clien
50ExampleThis example outputs foo to the NetConnection Debugger:mySO = SharedObject.get("foo");trace(mySO.name);SharedObject.onStatusAvailab
Server-Side Communication ActionScript 51Local shared objectsNote: Changing or deleting a property on the server side using the SharedObject.setProper
52ExampleThe following example creates a function that is invoked whenever a property of the shared object so changes:// create a new NetConnection ob
Server-Side Communication ActionScript 53SharedObject.resyncDepthAvailabilityFlash Communication Server MX.UsageSharedObject.resyncDepthDescriptionPro
54ReturnsA Boolean value of true if the message was sent to the client; false otherwise. DescriptionMethod; executes a method in a client-side script.
Server-Side Communication ActionScript 55If you call SharedObject.setProperty on the server side, it invokes a change message in the SharedObject.onSy
56UsagemySharedObject.unlock()ParametersNone.ReturnsAn integer indicating the lock count: 0 or greater if successful, -1 otherwise. For proxied shared
Server-Side Communication ActionScript 57You can create other Stream properties of any legal ActionScript type, including references to other ActionSc
58Stream.clearAvailabilityFlash Communication Server MX.UsageStream.clear()ParametersNone.ReturnsA Boolean value of true if the call succeeds, false o
Server-Side Communication ActionScript 59ExampleThis example gets the stream foo and assigns it to the variable playStream. It then calls the Stream.p
Managing the Server 15The Communication App inspector and NetConnection Debugger If you have Flash MX installed, you’ll find two new windows related t
60UsagemyStream.onStatus = function([infoObject]) {// Insert code here};ParametersinfoObject An optional parameter defined according to the status mes
Server-Side Communication ActionScript 61reset A Boolean value that flushes the playing stream. If reset is false, the server maintains a playlist, an
62ExampleThis example illustrates how streams can be chained between servers:application.myRemoteConn = new NetConnection();application.myRemoteConn.o
Server-Side Communication ActionScript 63Parametersflag This parameter can have the value record, append, or false. If the value is record, the data f
64DescriptionMethod; calls a method on all the clients subscribing to a stream. When you call Stream.send on the server side, any client publishing to
Server-Side Communication ActionScript 65traceAvailabilityFlash Communication Server MX.Usagetrace("Hello world");trace("Value of i = &
67APPENDIXServer-Side Information ObjectsThe Application, NetConnection, and Stream objects provide an onStatus event handler that uses an information
Appendix68NetConnection information objectsThe NetConnection object has the same information objects as the client-side NetConnection object. Stream i
Server-Side Information Objects 69NetStream.Failed Error An attempt to use a Stream method failed.*NetStream.Unpublish.Success Status An attempt to un
Chapter 216Using the Administration ConsoleYou can do common server administration and monitoring tasks using the graphical user interface of the Admi
Managing the Server 17You are now connected to the server, and the Diagnostics, Maintenance, Admin Users, Live Log, and License panels appear. These p
Chapter 218An application may have more than one instance if its clients connect to the server by using different application instance parameters with
Contents4
Managing the Server 19VHost Restart lets you restart a virtual host. Restarting a virtual host disconnects all users of that virtual host and removes
Chapter 220Adding and editing administratorsTo add or edit administrator log-on information, you use the Admin Users panel. The Admin Users panel con
Managing the Server 21To add an administrator:1 Select the server or the virtual host you want to add the administrator to. The server or virtual host
Chapter 222System lets you view server error messages, such as attempts to connect to nonexistent applications. When you select this option, server me
Managing the Server 23Configuring the server at runtime Using a special set of ActionScript commands, you can view and edit the server’s configuration
Chapter 224
25CHAPTER 3Configuring Flash Communication ServerMacromedia Flash Communication Server MX has been designed to accommodate many types of communication
Chapter 326The Web root directory in this scenario would contain all the components of your applications, such as the flashcom application directory a
Configuring Flash Communication Server 27Deployment: two computersIn this scenario the Flash Communication Server and application server are on two se
Chapter 328Deployment: two computers with authentication via Flash Communication ServerSome scenarios may require authentication of users who want to
5CHAPTER 1Introducing Flash Communication ServerWelcome to Macromedia Flash Communication Server MX—the easiest way to create rich communication appli
Configuring Flash Communication Server 29Deployment: two computers with authentication via an application serverYou may decide to have users authentic
Chapter 330About the configuration hierarchyFlash Communication Server can support several adaptors, virtual hosts, and applications simultaneously. E
Configuring Flash Communication Server 31A typical customized server conf directory might look like this:A customized conf directory containing multip
Chapter 332In the preceding example, each virtual host directory contains a subdirectory named applications. Each virtual host’s Vhost.xml must define
Configuring Flash Communication Server 33The Server.xml file contains the following tag structure, along with comments that briefly describe each tag.
Chapter 334• The <User> tag inside the <UserList> tag specifies the user name of a server administrator in its name parameter and is a con
Configuring Flash Communication Server 35• <Order> specifies the order in which to evaluate the preceding <Allow> and <Deny> tags. I
Chapter 336• The <Order> tag inside the <VirtualHost> tag works the same way as the <Order> tag inside the earlier <Server> ta
Configuring Flash Communication Server 37The following set of Server.xml tags has been customized for real-world use. Two server administrators are de
Chapter 338The Adaptor.xml file The Adaptor.xml file defines settings for an adaptor. It determines the number of threads that can be used by the adap
Chapter 16The Flash Communication Server instructional media includes the following documentation:• This manual, Getting Started with Flash Communicat
Configuring Flash Communication Server 39• <HostPort> specifies the IP address and one or more port numbers for the adaptor to bind to. The IP a
Chapter 340The Vhost.xml file contains the following tag structure, with brief comments for each tag:<VirtualHost><AliasList><Alias>
Configuring Flash Communication Server 41• <AppsDir> specifies the path to the flashcom application directory for this virtual host. The applica
Chapter 342• <MaxSharedObjects> specifies the maximum number of shared objects that the virtual host can create. (For more information about sha
Configuring Flash Communication Server 43The following set of Vhost.xml tags has been customized for real-world use. The alias stream is defined for t
Chapter 344The Application.xml file contains the following tag structure, with brief comments for each tag:<Application><LoadOnStartup>fal
Configuring Flash Communication Server 45• <JSEngine> is a container for the next two tags, which control the resource usage of the Server-Side
Chapter 346• The <StorageDir> tag inside the <SharedObjManager> tag indicates the directory where shared objects should be stored. The def
Configuring Flash Communication Server 47The following set of Application.xml tags has been customized for real-world use. The <RecordAppLog> ta
Chapter 348
Introducing Flash Communication Server 7Using additional resourcesThe Flash Communication Server Support Center website at www.macromedia.com/go/flash
49CHAPTER 4Understanding Flash CommunicationServer SecurityMacromedia Flash Communication Server MX will typically be used in a network environment wh
Chapter 450• Server.xmlThe <User> tags allow you to specify exactly who can connect to the server with the Administration Console. Only users sp
Understanding Flash Communication Server Security 51• Application.xmlThe <JSEngine>:<RuntimeSize> tag lets you limit the amount of memory
Chapter 452To have the server perform authentication of connecting users other than administrators, use the <Allow> and <Deny> tags in the
Understanding Flash Communication Server Security 53Use server-side script precautions. In server-side scripts do not use procedures that can be calle
Chapter 454You can also configure a firewall to provide additional protection against outside attacks. For example, if the server is being flooded by
55INDEXAAdaptor tag (Adaptor.xml file) 38Adaptor tag (Server.xml file) 35adaptors, configuring 38Adaptor.xml file 38Adaptor tag 38Allow tag 39Ho
Index56Application.xml file (continued)StorageDir tag 45, 46StreamManager tag 45AppsDir tag 41authentication 28, 29, 51authoring components 10
Index 57RRecordAccessLog tag 41RecordAppLog tag 44reloading applications 18removing applications 18ResourceLimits tag (Adaptor.xml file) 38Resour
macromedia™®Developing CommunicationApplicationsMacromedia Flash™ Communication Server MX
Chapter 18
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
3CONTENTSINTRODUCTIONAbout This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Intended a
Contents4CHAPTER 4Application Development Tips and Tricks. . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Application design and development
About This Manual 5INTRODUCTIONAbout This ManualWelcome to Macromedia Flash Communication Server MX!The Flash Communication Server provides the techno
Introduction 6Typographical conventionsThe following typographical conventions are used in this manual:• Code font indicates ActionScript statements,
7CHAPTER 1About Flash Communication ServerMacromedia Flash Communication Server MX, the new platform for interactive personal communication, integrate
Chapter 18Communications pass through the Flash Communication Server and are delivered to the client—the Flash Player on a user’s computer—by means of
About Flash Communication Server 9The Flash Communication Server lets you stream live media (audio, video, and data) or record data to be played later
Chapter 110To create audio/video applications, you must have audio/video capture devices (such as a camera and microphone), Flash MX authoring softwar
About Flash Communication Server 11Flash Communication Server objectsAs mentioned earlier, Flash Communication Server provides two application program
9CHAPTER 2Installation and WorkflowMacromedia Flash Communication Server MX is a development framework and a deployment environment for rich communica
Chapter 112Local shared objectClient-side local shared objects let you store information on a user’s computer, such as the high score in a game, that
About Flash Communication Server 13Remote shared object. Remote shared objects are created on the client but are also available to the server. They le
Chapter 114Understanding shared objectsShared objects are a means for sharing data among different clients, among different instances of an applicatio
About Flash Communication Server 15The flashcom application directoryWhen your Flash application requires the Flash Communication Server, you must pla
Chapter 116Using application instancesTo distinguish among different instances of a single application, pass a value for instanceName to your NetConne
About Flash Communication Server 17Setting up your development environmentTo write Flash Communication Server applications, you must install the Flash
Chapter 118Starting the serviceDuring server installation, you might have chosen to start the service automatically. If you did, the service will be s
About Flash Communication Server 19Writing your first applicationThe Flash Communication Server installation includes a sample application called doc_
Chapter 120Recreating the sampleThis sample assumes you are using the Flash MX authoring environment on the computer that is running the Flash Communi
About Flash Communication Server 213 Create a connection function that connects to the Flash Communication Server, displays a trace message indicating
Comments to this Manuals