MACROMEDIA FLASH MEDIA SERVER 2-DEVELOPING MEDIA Develop Manual

Developing media applications
Table of Contents

Advertisement

Quick Links

Developing Media Applications

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA FLASH MEDIA SERVER 2-DEVELOPING MEDIA

  • Page 1 Developing Media Applications...
  • Page 2 If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
  • Page 3: Table Of Contents

    Contents About This Manual........7 Intended audience .
  • Page 4 Chapter 3: Using Media Classes ......37 About Flash Media Server classes ......37 About Client-side classes .
  • Page 5 Chapter 5: Debugging and Monitoring Applications ..65 Using the management console to debug and monitor application . 65 Connecting the management console to a server ....66 About the View Applications panel .
  • Page 7: About This Manual

    Welcome to Macromedia Flash Media Server 2—a powerful server platform for creating rich media applications in Macromedia Flash and for streaming audio and video to Flash clients. Flash Media Server (FMS) can enable two or more people to participate in a real-time conversation using text, audio, or video.
  • Page 8: About The Flash Media Server Documentation

    Adobe Acrobat Reader) on the Flash Media Server CD and on the Macromedia web site as Flash Help in the Macromedia Flash application (select Help > Flash Help). Flash Media Server documentation is also available in LiveDoc format on the Macromedia web site.
  • Page 9: Support For Learning About Flash Media Server

    Media Server users. For late-breaking information and a complete list of issues that are still outstanding, read Flash Media Server release notes. Macromedia recommends several websites with links to third-party resources on Flash Media Server, including the following: Macromedia Flash community sites...
  • Page 10 About This Manual...
  • Page 11: Chapter 1: Getting Started

    This chapter describes initial steps you need to take before you begin developing applications with Macromedia Flash Media Server 2. It describes how to set up your development environment, how to deploy your applications, and how to create a simple application to connect to the server.
  • Page 12 Flash Player Make sure that you are using the latest version of Flash Player. You can download Flash Player from the Macromedia website at www.macromedia.com/go/ getflashplayer. If you are running Flash Media Server on Linux, you’ll need a Windows or Macintosh computer with Flash to create your media applications, and you’ll need to install the...
  • Page 13: Creating A Development Environment

    Creating a development environment This section explains what you need to know before you create Flash Media Server applications. Make sure the server is running To publish and test your applications, Flash Media Server must be running. For more information, see “Starting the service”...
  • Page 14: Preview Of Development Tasks

    Acknowledging the user’s right to privacy Before you record or broadcast anyone’s image or voice, it’s important to inform that person of your intention and to gain their consent or agreement. Monitoring running applications If you have server administration permissions, you can view details about an application while you are testing it, such as log messages it is generating, values of shared objects, and so on.
  • Page 15: Deploying Applications And Application Instances

    Depending on your application, additional steps are required; however, these steps are necessary for all applications, regardless of their functionality. Macromedia recommends that you use all lowercase letters and no spaces when you name directories and files used with Flash Media Server and its applications. This practice helps to ensure that, during development, your applications will work if you move files to different computers on different platforms.
  • Page 16: Storing Your Application's Server-Side Script Files

    For organizational purposes during your development work, it might be convenient to store all of our client and server application files (FLA, SWF, HTML, or ASC) in one subdirectory. When you deploy your application, you can place your SWF and HTML files in any location. However, the registered application directory must remain on the Flash Media Server server, along with any ASC, FSO, and FLV files that the application uses.
  • Page 17: About Application Instances

    About application instances Applications are run by creating application instances. When a client connects to an application, the client is actually connected to an application instance. For example, a client connects to an application named chat_app, as the following example shows: nc.connect(“rtmp://myDomain.com/chat_app”);...
  • Page 18: File Types Used By Flash Media Server

    second_nc.connect("myserver.mydomain.com/support/session2"); second_so = SharedObject.getRemote("CustomerInfo", second_nc.URI, false); second_so.connect(second_nc.URI); Instance name is frequently used, but you can use any string for an instance name room_01 that makes sense in your application. You can configure several settings related to application instances. In the Application.xml file, you can configure the maximum idle time before the server unloads an instance.
  • Page 19: Connecting To The Server

    If the server is not already started, you can start it manually. From the Windows Start menu, select Programs > Macromedia > Macromedia Flash Media Server 2> Start Flash Media Admin Server and Flash Media Server. On Windows, to confirm that the service is running, open the Task Manager and make sure that both FMSAdmin.exe and FMSMaster.exe are...
  • Page 20: Opening A Connection To The Server

    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: In a new Flash application, begin opening a connection by issuing the following command: my_nc = new NetConnection();...
  • Page 21: Chapter 2: Flash Media Server Architecture

    Flash Media Server Architecture The Macromedia Flash Media Server 2 platform is made up of two parts: the server and Macromedia Flash Player. Applications built on this platform consist of a client Macromedia Flash application (SWF file) that is run by Flash Player, and a server component that communicates with the client.
  • Page 22: Understanding The Flash Media Server Architecture

    Understanding the Flash Media Server architecture The server and the Flash client application communicate over a persistent connection using Real-Time Message Protocol (RTMP). In a typical scenario, a web server delivers the Flash client to Flash Player over HTTP. The Flash client then uses RTMP to establish a persistent connection to Flash Media Server, allowing for an uninterrupted data stream to flow between client and server.
  • Page 23: About Streams And Shared Objects

    Multiple users (Flash clients) can connect to the same application running on Flash Media Server, which acts as a communication channel between connected users. Client 1 Client 2 Server Flash Media Server provides a channel of communication for clients. You can also create secure RTMPS connections. For more information, see in the client-side and server-side ActionScript Language NetConnection.connect() References.
  • Page 24 Recorded streams are saved in the Flash Video (FLV) format. Recorded streams can contain data messages, as well as video. You can also create FLV files from existing digital video or audio files by using third-party video encoding utilities, like On2 or Sorenson Squeeze, or export them from Flash.
  • Page 25 Understanding shared objects The two basic types of shared objects you can use when you create media applications are local and remote. You can think of local shared objects as “Flash cookies”: they let you save data to a user’s computer for off-line access, or for saving preferences.
  • Page 26: About Connecting To External Data Sources

    End user Flash Media Server interacts with external data sources. Macromedia Flash Remoting is a gateway that connects your media application to J2EE application servers and Microsoft Windows .NET servers. You can connect to Flash Remoting from a client-side or server-side script. Flash Remoting relies on its own ActionScript library, called NetServices, to link Macromedia Flash applications to a server-side gateway.
  • Page 27: Workflow For Creating And Deploying Applications

    Workflow for creating and deploying applications You use the Flash authoring tool to create your application’s client component, which runs in Flash Player. The Flash SWF file provides the application’s user interface, and also contains ActionScript for connecting to, and managing interactions with, Flash Media Server. For more information on client-side Media ActionScript, see the Client-Side ActionScript Language Reference for Flash Media Server 2.
  • Page 28 The server files, including any ASC files, recorded stream (FLV) files and other server-side resource files, are published to the registered application directory you’ve defined on the server. SWF FILE . swf Flash logic ActionScript <HTML> . swf </ HTML> .
  • Page 29: Understanding Application Flow

    If you’re an administrator, you’ll use the management console to configure Flash Media Server, set up system security, monitor usage, start and stop the server, and add users. For more information on administration tasks for Flash Media Server, see Managing Flash Media Server.
  • Page 30: Understanding Connection Flow

    Understanding connection flow The client connects to the server, and the server calls when the application onAppStart instance is loaded (if the application is already running, is not called). Next, the onAppStart server-side handler is invoked with a newly created Client object. The logic in this onConnect method determines whether to accept or reject the connection.
  • Page 31: Invoking Remote Methods

    Invoking remote methods After a successful connection, the client can invoke remote methods that the server component defines; the server application can also remotely invoke ActionScript methods defined in the Flash client application. Invoking server methods from the client Each Flash application that connects to a server application is represented by a Client object, which is an instance of the server-side Client class.
  • Page 32 The following table lists Flash Media Server Client Status Messages: Code Level Meaning Status A recorded stream was deleted successfully. NetStream.Clear.Success Error A recorded stream failed to delete. NetStream.Clear.Failed Status An attempt to publish was successful. NetStream.Publish.Start Error An attempt was made to publish a stream NetStream.Publish.BadName that is already being published by someone else.
  • Page 33 For more information on invoking server methods remotely, see the Client."commandName" entry in the Server-Side ActionScript Language Reference. Invoking client methods from the server The process for invoking client-defined methods from the server is similar to the reverse case. On the client, you can attach a user-defined method to the NetConnection object used to connect to the server.
  • Page 34: Understanding Shared Object Flow

    Code Level Meaning Error An attempt was made to record a read-only NetStream.Record.NoAccess stream. Status Recording was stopped. NetStream.Record.Stop Error An attempt to record a stream failed. NetStream.Record.Failed Status Play was started. NetStream.Play.Start Error An attempt was made to play a stream that NetStream.Play.StreamNotFound does not exist.
  • Page 35 After the client is connected to the shared object, the server sends out a synchronization message for the shared object, which is handled by the event handler SharedObject.onSync defined on the client. When the client, the server, or any other movie instance makes a change to the shared object, the server again sends out a synchronization message for the shared object.
  • Page 36 Flash Media Server Architecture...
  • Page 37: Chapter 3: Using Media Classes

    CHAPTER 3 Using Media Classes Macromedia Flash Media Server provides two application program interfaces (APIs): a client- side API and a server-side API. This chapter explains the client-side classes, the server-side classes, and how objects created from these classes are paired during communication. Shared objects are also discussed, as they store information about the application and users for sharing between users, application instances, and applications.
  • Page 38 Camera class The client-side Camera class lets you capture video from a video camera attached to any computer running Macromedia Flash Player. When used with Flash Media Server, this class lets you transmit, display, and optionally record the video being captured.
  • Page 39: About Server-Side Classes

    Using a NetConnection object, you can connect to an application server for server-to-server interactions using standard protocols (such as HTTP), or connect to another Flash Media Server for sharing audio, video, and data using the Macromedia Real-Time Messaging Protocol (RTMP).
  • Page 40: About Client-Server Communication

    You can use Macromedia Flash Remoting with the Flash Media Server to communicate with application servers such as Macromedia ColdFusion, .NET, and J2EE servers. For more information, see the Flash Remoting information on the Macromedia website at www.macromedia.com/go/flashremoting. SharedObject class Server-side shared objects let you communicate with client-side shared objects and with objects on other Flash Media Servers.
  • Page 41: Understanding Shared Objects

    In the following table, the client-side calls on the left invoke the server-side calls on the right. Client-side call Server-side call my_nc.connect application.onConnect my_nc.close application.onDisconnect my_nc.call("doThing", myCallbackFcn, 1, "foo") my_client.doThing(1, "foo") my_so.send("doThing", 1, "foo") my_server_so.doThing(1, "foo") In the following table, the server-side calls on the left invoke the client-side calls on the right. Server-side call Client-side call my_client.call ("doThing", myCallbackFcn, 1, "foo") my_nc.doThing (1, "foo")
  • Page 42: About The Application Class

    About remote shared objects Using client-side ActionScript, you can create and reference shared objects that are available to other Flash Media Server application instances running on the same or different clients. Like local shared objects, these objects can persist on the local computer. However, they can also persist on the server, so that any user who connects to the shared object has access to the same information.
  • Page 43: Using The Application.onconnect Handler

    For more information on the Application class, see the entry in the Application class Server-Side ActionScript Language Reference. Using the application.onConnect handler event handler is invoked on the server when a client calls the application.onConnect method. The handler handler is automatically NetConnection.connect() onConnect passed a reference to a server-side Client object, representing the client that’s attempting to...
  • Page 44 Also, if you want to use the method on the Client object that is connecting, make sure call() you call and know that the client is connected before application.acceptConnection() issuing any additional commands. The following code sets up this sequence of actions: application.onConnect = function(clientObj,name,passwd) // First accept the connection application.acceptConnection(clientObj);...
  • Page 45: Using The Application.ondisconnect Handler

    Using the application.onDisconnect handler The server calls the handler when a client disconnects from the application.onDisconnect application. You can add code to this handler that notifies all other clients about this event, as in the following example: // On the server side you would have the following application.onConnect = function(newClient, name) newClient.name = name;...
  • Page 46: Handling Events In A Component-Based Application

    Handling events in a component-based application When you develop applications, be aware that using components introduces explicit events. You need to include code to handle these onConnectAccept onConnectReject events. When you use components, you must modify the application.onConnect statement in your server-side code to include the application.onConnectAccept event handlers.
  • Page 47: Suggested Settings For Different Bandwidth Speeds

    Suggested settings for different bandwidth speeds The default camera settings provide a good viewing experience for all bandwidth settings. However, you can experiment with different settings for different bandwidths. The code for setting the bandwidth speeds is as follows: my_cam = Camera.get(); my_cam.setQuality(bandwidthSpeed,quality) Use the following table as a starting point if you want to experiment with camera settings at different bandwidth speeds.
  • Page 48: The Microphone Class

    The Microphone class This section includes recommendations for optimizing your use of the Microphone class, including tips on avoiding audio feedback. Avoiding audio feedback If you’re using a microphone with external speakers and a reasonably high gain, you’re likely to incur audio feedback problems.
  • Page 49: The Netconnection Class (Client-Side)

    The NetConnection class (client-side) If an HTML page containing a Flash application (SWF file) is accessed with a different domain name than the domain name the SWF file uses to access Flash Media Server, the connection to Flash Media Server will not be successful. This is a security feature of Flash Player.
  • Page 50: The Netstream Class

    The NetStream class This section includes recommendations for optimizing your use of the NetStream class, including tips on incorporating data into a stream, managing a stream’s buffer, and executing code when a stream has finished playback. Using multiple data types in a stream In addition to streaming audio and video, you can include data, such as a text message, in a stream.
  • Page 51: About Buffering A Stream

    Then, in the corresponding server-side ActionScript, you would add the following code in the main.asc file: application.onAppStart = function(){ trace("::: Application has started :::"); application.onConnect = function(client){ application.acceptConnection(client); // Add methods client.prototype.sendInfo = function(name) { var slen = Stream.length(name); trace("slen: " + slen); return slen;...
  • Page 52: The Sharedobject Class

    The SharedObject class Shared objects can be used for a wide number of purposes, and can be designed and used in a number of ways. This section provides some items to consider as you begin using shared objects in your applications. About synchronizing shared objects Before attempting to work with a remote shared object, you should first check that the method returned a value of...
  • Page 53: Flushing Remote Shared Objects

    On the other hand, if your application needs to send only information that has changed, then you should divide the data among multiple slots. This implementation reduces network traffic and thus enhances the performance of your application. It also minimizes the need for conflict resolution code, as multiple slots can be updated simultaneously without data collision.
  • Page 54 Assign 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 time. You might write server code to create a “lock” object, where a client can request ownership of a slot. If the server reports that the request was successful, the client knows that it will be the only client changing the data in the shared object.
  • Page 55: The Stream Class

    = Stream.get("foo"); if (s) s.clear(); The System class Macromedia Flash Media Server sends text in UTF-8 format. If you set the to a value of in your ActionScript code, your media application System.useCodepage true might not work properly.
  • Page 56: About The Video Class

    About the Video class This section includes recommendations for optimizing your use of the Video class, including tips on dynamically creating Video objects. For more information about video, see Chapter 4, “Working With Media Files.” About creating Video objects dynamically You can add Video objects to your application only from within the Flash authoring environment, by dragging an embedded Video object from the Library panel to the Stage.
  • Page 57: Chapter 4: Working With Media Files

    CHAPTER 4 Working With Media Files Macromedia Flash Media Server lets you deliver a broad range of media experiences. This chapter includes information about creating live web-event broadcasts, customizing stream delivery for individual clients, and MP3 publishing and playback. Working with video Flash Media Server lets you stream live and recorded video to Flash Player clients.
  • Page 58: Customizing Stream Delivery

    Customizing stream delivery You can use the Flash Media Server custom stream delivery feature to provide the best streaming experience for each client by serving different versions of the same stream to different clients. For example, you can provide video encoded with the Sorenson Spark codec to clients with Flash Player 7 and video encoded with the On2 VP6 codec to clients with Flash Player 8.
  • Page 59 Consider the following example: a user wants to play a stream and has Flash Player 8 installed on their computer. Flash Player 8 is capable of playing On2 video. Flash Media Server requests the HappyStream.flv file. After contacting the server, Flash Player 8 determines the value of the server-side property.
  • Page 60 Within the tag of the vhost.xml file, set the virtual key for Flash Player 7 and VirtualKeys below to and set the virtual key for Flash Player 7 (7.0.19.0) and later (the player version that supports the On2 codec) to , as in the following example: <VirtualKeys>...
  • Page 61 By default there are no values in the tags. To implement this feature, you must add the key values, either directly in the vhost.xml file, or with the Stream.setVirtualPath() method. For example, to implement this feature, set the first key to A, and the second two keys to B, as in the following code: <VirtualKeys>...
  • Page 62: Working With Mp3 Files

    Working with MP3 files In Flash Media Server applications, you can use client-side ActionScript to play MP3 audio files and to display the ID3 tags of MP3 files, and use server-side ActionScript to publish MP3 files over a stream. To do so, upload the MP3 files for your application to the /streams/application_instance subdirectory in your registered application directory.
  • Page 63 To display the ID3 tags of MP3 files, precede the stream name with and define a id3: callback function to capture the ID3 data. For example, to display the ID3 tag of bolero.mp3: // displays the ID3 tag of bolero.mp3 mystream_ns.play("id3:bolero");...
  • Page 64 To use the method to capture and display the text of ID3 tags, see the Stream.play() following example: // Set up the server stream application.myStream = Stream.get("description"); application.myStream.onId3 = function(info) for (i in info) trace(i + ": " + info[i]); if (application.myStream) // Publish the ID3 text tag data of bolero.mp3 to a stream "description".
  • Page 65: Chapter 5: Debugging And Monitoring Applications

    Streams tab. The streaming content is displayed live in a console pane. To open the management console, select Window > Other Panels > Management Console from within Macromedia Flash. On a server computer that doesn’t have Flash installed, open the management console HTML file located in the //Flash Media Server 2/fms_help/html/ admin directory.
  • Page 66: Connecting The Management Console To A Server

    The login screen of the management console lets you connect to a server. To connect to a server: In Windows, from the Windows Start menu, select Programs > Macromedia > Flash Media Server > Console. In Linux, open the fmsconsole.swf file in a web browser on a computer where Flash Player is installed.
  • Page 67: About The View Applications Panel

    To connect to this server automatically whenever you open the management console, select Automatically Connect Me. Click Login. The initial screen of the management console also has numerous links to Flash Media Server resources such as the Developer Center, Support Center, release notes, documentation, and online help.
  • Page 68 The View Applications panel lets you perform the following tasks: To manually load an application instance, click New Instance and select the application from the pop-up menu. The application must already be configured on the server. After selecting an application to load, you can enter a name for the application instance. To view information about a running application instance, select the application in the list.
  • Page 69: About The Live Log Panel

    About the Live Log panel The Live Log panel displays the log messages by the selected application instance on the server, such as trace () statements in the application. The information in this panel is updated whenever the application instance generates a log message, not just when the panel is refreshed.
  • Page 70: About The Clients Panel

    About the Clients panel The Clients panel displays detailed information about all of the clients connected to an application, including server-generated Client ID, connection protocol, bytes in and out, connection time, messages in and out, and dropped messages. The Clients panel shows information about clients connected to the selected application instance. The Clients panel displays the following information: Client ID indicates the internal ID of the client;...
  • Page 71: About The Shared Objects Panel

    Drops indicates the number of messages that have dropped since the client connected. For live streams, audio and video, messages may be dropped; for recorded streams, only video messages are dropped. Command messages are never dropped. This panel lets you perform the following tasks. To customize this panel, click the pop-up menu in the far-right column and select the columns to display.
  • Page 72 Shared objects can be remotely persistent (they are stored on the server and are still available after an application instance or server is stopped and restarted), or available only for the life of the instance (they are temporary, and are deleted when the instance stops running). The Shared Objects panel displays information on both types of shared objects that the application instance uses.
  • Page 73: About The Streams Panel

    About the Streams panel The Streams panel lets you view information about and play streams. The information is automatically refreshed every 5 seconds, or you can click Refresh to refresh at any time. The Streams panel provides details about streams and lets you play a stream. The Streams panel displays the following information.: Name indicates either the stream name or NetStream ID.
  • Page 74: About The Performance Panel

    The Streams panel lets you perform the following tasks: To customize this panel, click the pop-up menus and select or deselect the columns to display. Click Play Stream to start playing the selected stream in a separate window that is the size of the selected stream.
  • Page 75 The Performance panel displays the following information: Clients provides information about clients connected to this application instance including the total number of clients who connected to the application instance since it started, active clients, and the number of users whose attempts to connect to the application instance were rejected.
  • Page 76: Using A Debug Connection

    Using a debug connection For playing back streams and obtaining data from shared objects, the management console must make a special debug connection to the server. By default, the server does not allow this. You must change this in Application.xml. The debug connection counts as a regular user and counts against license limits.
  • Page 77: Where To Use Onstatus Handlers In A Script

    For more information about the values that various handlers return, see the Client- onStatus Side ActionScript Language Reference for Flash Media Server 2. The following table summarizes the information objects that certain server-side calls return; the server-side call on the left invokes the client-side handler with the code value on the right.
  • Page 78: About The System.onstatus Handler

    About the System.onStatus handler In addition to the specific methods provided for the classes listed in “About onStatus onStatus event handlers” on page 76, Flash also provides a “super handler” called . If is invoked for a particular object with a level property of System.onStatus onStatus and no function is assigned to respond to it, Flash processes a function assigned to...
  • Page 79: Tracing The Properties Of An Object

    Tracing the properties of an object To find out why you might be having problems with a particular object, you can iterate its properties as follows: for (i in my_obj) { trace(i + " = " + my_obj[i]); Tracing the properties of an object...
  • Page 80 Debugging and Monitoring Applications...
  • Page 81: Chapter 6: Application Development Tips And Tricks

    Tips and Tricks This chapter points out some useful information about application development that is specific to Macromedia Flash Media Server. It includes general sections on application design and coding conventions. Read this chapter after you are familiar with the concepts described in Chapters 1 and 2.
  • Page 82: About Shared Object Files

    To avoid overwriting streams, consider using unique names for users, streams, and so on. For example, when recording a new stream, you could provide an incremental value: outStream.publish("myRecording" + numSnaps, "record"); For information on deleting recorded stream files, see “The Stream class” on page 55.
  • Page 83: Portability Across Servers

    Name application elements using all lowercase text. Macromedia recommends that you use all lowercase letters and no spaces when you name directories and files used with Flash Media Server and its applications. This practice helps to ensure that, during development, your applications work if you move files to different computers on different platforms.
  • Page 84: Client-Server Script Interdependence

    If your SWF file is on the same computer that is running the Flash Media Server, you can use rtmp:/appName/instanceName as a shortcut version of rtmp://server.domain.com/appName/ instanceName. If you are authoring your application on a development server and don’t use a relative path in your SWF files, moving all of your SWF files to a production server could create some extra work, because each Uniform Resource Identifier (URI) in the statement in your SWF files must be edited to connect to the...
  • Page 85: Using Multiple Script Files

    In contrast, suppose you use the method from the client, to call a method on the call() server side: // This is client-side ActionScript in the FLA file. NetConnection.call("someServerMethod"); // This is server-side ActionScript in the main.asc file. client.prototype.someServerMethod = function(){ // code here // The following code would also work.
  • Page 86: Archiving And Compiling Server-Side Script Files

    On the server side, you must implement slightly different code; server-side ActionScript does not contain a global object. The following code includes a file called my_file.asc: if (_my_file_asc == null) { _my_file_asc = true; // All the code for myfile.asc goes here. Also, instead of using the command, the server-side script uses a command, as...
  • Page 87 When scripts in the FAR file refer to other script files in a scriptlib path, Macromedia recommends that you place all of the required script files from the path into the FAR file. This placement prevents an application from loading a different version of the script file with the same name from a different computer.
  • Page 88 To understand how to use a FAR file in an application, consider the following example, which is based on an application called testFAR. The following is the directory of the testFAR application:. The main script is called testFAR.asc and is located in the scripts directory: The testFAR.asc file uses the web services that are provided in the script library directory (<installdir>\scriptlib).
  • Page 89: Compiling Scripts To Bytecode

    Media Server looks for the script files in the FAR file. The scriptlib is defined in the fcs.ini file as in the following example: APP.JS_SCRIPTLIBPATH = C:\Program Files\Macromedia\Flash Communication Server MX\scriptlib To include a FAR file in the scriptlib path, use the following code: APP.JS_SCRIPTLIBPATH = C:\Program Files\Macromedia\Flash Communication...
  • Page 90 To compile server-side scripts to bytecode: Open your operating system’s command shell. Enter far -compile with the desired options at the prompt. Add the location of the FAR utility to the PATH environment variable. This addition lets you run the FAR utility without having to specify the full path to the executable. The syntax for running the archive compiler utility to create a script package is as follows: c:\>...
  • Page 91: Forcing The Player Settings Panel To Appear

    Option Description Optional. Do not display the Macromedia copyright logo when running this utility. You may want to set this option if you are running the utility from an automated script. Optional. Displays the help for using this utility. You can -h [<command>]...
  • Page 92: Managing Bandwidth

    Managing bandwidth You can control the amount of data the server sends to each client by providing an approximate bandwidth capacity. You can do so in several ways. One way is to configure the capacity for the Flash Media Server in the configuration file (Config.xml). For more information on this technique, see Managing Flash Media Server.
  • Page 93: Writing Double-Byte Applications

    Or the design can be more detailed and include content switching in the NetStream, as in the following: ns = new NetStream(nc); ns.onStatus = function(info){ if (info.code == "NetStream.Play.InsufficientBW"){ // Switch to play a content that requires less bandwidth. curTime = this.time; this.play("foo_low_bandwidth", curTime, -1, true);...
  • Page 94: About Unloading And Reloading Applications

    About unloading and reloading applications Application instances are usually unloaded because of garbage collection. The first time the garbage collector runs after all clients are disconnected from an application, the application is unloaded. In other words, applications aren’t unloaded immediately when all clients disconnect.
  • Page 95: Developing Secure Applications

    If you set the read access as follows: client.readAccess = "appSO/" the server allows all connected clients to subscribe to shared objects with names that begin with appSO Similarly, you can make the call: client.writeAccess= "appSO/public/" and the client can create only shared objects with names that begin with , such appSO/public , but is denied access to...
  • Page 96: Protecting Scripts From Third-Party Code

    To use RTMPS, you replace in your NetConnection.connect call with . If you rtmp rtmps don’t specify a port number, Flash Player connects on the default secure port, port 443. A secure port is designated with a minus sign. For example, <HostPort>:1935,80,-443</ HostPort>.
  • Page 97 This section provides information about creating protected objects (also called system objects) and provides examples of how to make both synchronous and asynchronous calls to those objects. Understanding system objects A system object is a built-in or user-defined object wrapped in C-layer code that protects the object from application code.
  • Page 98: Simple-System Call Example

    Simple-system call example The following simple-system call example implements an ID generator. The generator must generate an increasing number for each new ID. If you write the generator code in the main.asc file, any part of the script could easily redefine the function or directly nextID() modify the...
  • Page 99: Asynchronous System Calls

    The following secure.asc example shows how to wrap a built-in global function—in this case . After secure.asc is executed, calls to are directed through the user-defined load() load() system call, as follows: var sysobj = {}; sysobj._load = load; // Hide the load function. load = null;...
  • Page 100 The Flash Media Server does not maintain privilege levels explicitly. For example, an asynchronous call set up by normal application code cannot be privileged. However asynchronous calls set up within the system object can choose to complete the calls either as privileged or unprivileged.
  • Page 101: Coding Conventions

    In addition, never use as names words that ActionScript uses (reserved words). Also avoid using variable names of common programming constructs, even if the Macromedia Flash Player does not currently support those constructs. This practice helps to ensure that future versions of the Player will not conflict with the application.
  • Page 102: Naming Variables To Support Code Hinting

    Naming variables to support code hinting The Macromedia Flash ActionScript editor has built-in code hinting support. To take advantage of this, you can either use strict typing syntax for the variables (new in ActionScript 2.0) or use a specific format to name the variables. The default format is to add a suffix to the variable name that indicates the variable type.
  • Page 103: Commenting Your Code

    For more information on strict typing and code hints, see Learning ActionScript 2.0 in Flash or search for “strict data typing” or “code hints” in Flash Help. Commenting your code Always comment code in an application. Comments are the author’s opportunity to tell a story about what the code was written to do.
  • Page 104: Initializing Applications

    Initializing applications Initialization of an application is used to set the starting state. It should be the first function call in the application. This function should be the only call for initialization made in your program; all other calls should be event driven. // frame 1 this.init();...
  • Page 105 In this case, the variable on the main timeline is overwritten by the variable counter counter within the function. The following is the corrected code, which uses the keyword counter declare both of the variables: var counter = 7; function loopTest(){ trace(counter);...
  • Page 106 Application Development Tips and Tricks...
  • Page 107: Index

    Index Symbols bytes per second 75 cameras, using in 47 #include command 85 checklists for creating 14 client-server communication 84 clients, viewing connected 75 commenting code 103 ACL (access control list), implementing 94 connecting to the server 43 ActionScript CPU and memory usage 75 client-side and server-side 85 creating a development environment 13 commands for connecting to server 19...
  • Page 108 Client class about 39 bandwidth and client-side NetConnection object 84 and microphones 48 call() method 44 bytes per second 75 readAccess property 94 management console, viewing in 75 receiving messages from the client 39 managing 92 setBandwidthLimit() method 92 speed settings 47 tips and tricks 47 bytecode, compiling scripts to 89 virtualKey property 58...
  • Page 109 support for learning about 9 third-party resources 9 deleting recorded stream files 55 tips and tricks 81 deploying applications 15 Flash Player 11 designing applications Flash Player Settings panel 91 for interdependence 84 Flash Remoting 40 for portability across servers 83 FLV files Developer Center for Flash Media Server 9 about 16, 19...
  • Page 110 Microphone.useEchoSuppression() method 48 MP3 files level property. See information objects about 62 Linux 12 controlling with ActionScript 63 Live Log panel 69 ID3 tags 63 live stream. See streams publishing 63 loading the components.asc file 13 multiple files, using 85 LoadVars class 39 local shared objects.
  • Page 111 NetStream.attachVideo() method 46 NetStream.bufferLength property 50, 51 read/write access, shared objects 94 NetStream.bufferLength propery 51 recorded streams NetStream.bufferStream property 51 avoiding collisions 17 NetStream.bufferTime property 51 deleting files 55 NetStream.play() method 38 files for 81 about 40 refresh rate. See management console and ID3 tags 63 registered application directory 14 and Video object 38...
  • Page 112 file location 82 SOL and SOR files 19 file types 19 Sorenson H263 codec 58 flushing on server 53 SSL (Secure Sockets Layer) 95 local 38, 41 Stream class locking 54 about 40 management console, viewing in 71 get() method 40 name, viewing 71 tips and tricks 55 persistence, local and remote 82...
  • Page 113 Video.attachVideo() method 38 virtual directories technical support 9 about 58, 60 text, encoding 55 mapping 60 third-party resources for Flash Media Server 9 virtual keys troubleshooting about 58, 60 application won’t connect to server 78 mapping 60 NetConnection.Connect.Failed message 78 type of stream, in Streams panel 73 warning property.

This manual is also suitable for:

Flash media server 2

Table of Contents