Macromedia Media Server - 5.0.3 User Guide

Server-Side ACTIONSCRIPT® Language
®
Reference for ADOBE
MEDIA
SERVER
Legal notices
For legal notices, see http://help.adobe.com/en_US/legalnotices/index.html.
Last updated 9/20/2013

Contents

Server-Side ActionScript Language Reference
Adobe Media Server server-side APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Global functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Application class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
ByteArray class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Client class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
File class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
GroupSpecifier class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
GroupControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
LoadVars class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Log class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
MulticastStreamInfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
MulticastStreamIngest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
NetConnection class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
NetGroup class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
NetGroupInfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
NetGroupReceiveMode class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
NetGroupReplicationStrategy class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
NetGroupSendMode class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
NetGroupSendResult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
NetStream class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
ProxyStream class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
SharedObject class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
SHA256 class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
SOAPCall class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
SOAPFault class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Stream class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
iii
Last updated 9/20/2013

Server-Side ActionScript Language Reference

Use Server-Side ActionScript™ to write server-side code for an Adobe® Media Server application. You can use Server­Side ActionScript to control login procedures, control events, communicate with other servers, allow and disallow users access to various server-side application resources, and let users update and share information.

Adobe Media Server server-side APIs

Server-Side ActionScript is Adobe’s name for JavaScript 1.5. Adobe Media Server has an embedded Java-Script engine that compiles and executes server-side scripts. This Server-Side ActionScript Language Reference documents the Adobe Media Server host environment classes and functions. You can also use core Java-Script classes, functions, statements, and operators. For more information, see the Mozilla JavaScript documentation at
http://developer.mozilla.org/en/JavaScript.
1
Server-Side ActionScript is similar, but not identical, to ActionScript 1.0. Both languages are based on ECMAScript (ECMA-262) edition 3 language specification. Server-Side ActionScript runs in the Mozilla SpiderMonkey engine embedded in Adobe Media Server. ActionScript 1.0 runs in AVM1 (ActionScript Virtual Machine 1) in Adobe® Flash® Player. SpiderMonkey implemented the ECMAScript specification exactly and Flash Player AVM1 did not. The biggest difference between Server-Side ActionScript and ActionScript 1.0 is that Server-Side ActionScript is case­sensitive.

Global functions

The following functions are available anywhere in a server-side script:
Signature Description
clearInterval() Stops a call to the setInterval() method.
getGlobal() Provides access to the global object from the secure.asc file while the file is loading.
load() Loads a Server-Side ActionScript file (ASC) or JavaScript file (JS) into the main.asc file.
protectObject() Protects the methods of an object from application code.
setAttributes() Prevents certain methods and properties from being enumerated, written, and deleted.
setInterval() Calls a function or method at a specified time interval until the clearInterval() method is called.
trace() Evaluates an expression and displays the value.

clearInterval()

clearInterval(intervalID)
Stops a call to the setInterval() method.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Communication Server 1
Parameters
intervalID An identifier that contains the value returned by a previous call to the setInterval() method.
Example
The following example creates a function named callback() and passes it to the setInterval() method, which is called every 1000 milliseconds and outputs the message
"interval called." The setInterval() method returns a
number that is assigned to the intervalID variable. The identifier lets you cancel a specific setInterval() call. In the last line of code, the
function callback(){trace("interval called");} var intervalID; intervalID = setInterval(callback, 1000); // sometime later clearInterval(intervalID);
intervalID variable is passed to the clearInterval() method to cancel the setInterval() call.

getGlobal()

getGlobal()
2
Provides access to the global object from the secure.asc file while the file is loading. Use the getGlobal() function to create protected system calls.
Availability
Flash Media Server 2
Details
Adobe Media Server has two script execution modes: secure and normal. In secure mode, only the secure.asc file (if it exists) is loaded and evaluated—no other application scripts are loaded. The
getGlobal() and protectObject()
functions are available only in secure mode. These functions are very powerful because they provide complete access to the script execution environment and let you create system objects. Once the secure.asc file is loaded, the server switches to normal script execution mode until the application is unloaded.
To prevent inadvertent access to the global object, always hold its reference in a temporary variable (declared by var); do not hold its reference in a member variable or a global variable.
Example
The following code gets a reference to the global object:
var global = getGlobal();

load()

load(filename)
Loads a Server-Side ActionScript file (ASC) or JavaScript file (JS) into the main.asc file. Call this function to load ActionScript libraries. The loaded file is compiled and executed after the main.asc file is successfully loaded, compiled, and executed, but before
application.onAppStart() is called. The path of the specified file is resolved relative to
the main.asc file.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Communication Server 1
Parameters
filename A string indicating the relative path to a script file from the main.asc file.
Example
The following example loads the myLoadedFile.asc file:
load("myLoadedFile.asc");

protectObject()

protectObject(object)
Protects the methods of an object from application code. Application code cannot access or inspect the methods directly. You can use this function only in the secure.asc file.
Availability
Flash Media Server 2
3
Parameters
object An object to protect.
Returns
An Object.
Details
After an object is protected, don’t reference it in global variables or make it a member of an accessible object. The object returned by
protectObject() dispatches all method invocations to the underlying object but blocks access to
member data. As a result, you can’t enumerate or modify members directly. The protected object keeps an outstanding reference to the underlying object, which ensures that the object is valid. The protected object follows normal reference rules and exists while it is referred to.
Adobe Media Server has two script execution modes: secure and normal. In secure mode, only the secure.asc file (if it exists) is loaded and evaluated—no other application scripts are loaded. The
getGlobal() and protectObject()
functions are available only in secure mode. These functions are very powerful because they provide complete access to the script execution environment and let you create system objects. Once the secure.asc file is loaded, the server switches to normal script execution mode until the application is unloaded.
Example
After secure.asc is executed, calls to load() are directed through the user-defined system call, as shown in the following example:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
var sysobj = {}; sysobj._load = load; // Hide the load function load = null; // Make it unavailable unpriviliged code. sysobj.load = function(fname){ // User-defined code to validate/modify fname return this._load(fname); } // Grab the global object. var global = getGlobal();
// Now protect sysobj and make it available as // "system" globally. Also, set its attributes // so that it is read-only and not deletable.
global["system"] = protectObject(sysobj);
setAttributes(global, "system", false, true, true);
// Now add a global load() function for compatibility. // Make it read-only and nondeletable.
global["load"] = function(path){ return system.load(path); }
setAttributes(global, "load", false, true, true);
4
See also
LoadVars class

setAttributes()

setAttributes(object, propName, enumerable, readonly, permanent)
Prevents certain methods and properties from being enumerated, written, and deleted. In a server-side script, all properties in an object are enumerable, writable, and deletable by default. Call attributes of a property or to define constants.
Availability
Flash Media Server 2
Parameters
object An Object.
propName A string indicating the name of the property in the object parameter. Setting attributes on nonexistent
properties has no effect.
enumerable One of the following values: true, false, or null. Makes a property enumerable if true or
nonenumerable if enumerations (
readonly One of the following values: true, false, or null. Makes a property read-only if true or writable if false;
null value leaves this attribute unchanged. Any attempt to assign a new value is ignored. Typically, you assign a value
a
false; a null value leaves this attribute unchanged. Nonenumerable properties are hidden from
forvariinobj).
to a property while the property is writable and then make the property read-only.
setAttributes() to change the default
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
permanent One of the following values: true, false, or null. Makes a property permanent (nondeletable) if true
or deletable if calling
false; a null value leaves this attribute unchanged. Any attempt to delete a permanent property (by
deleteobj.prop) is ignored.
Example
The following code prevents the resolve() method from appearing in enumerations:
Object.prototype.__resolve = function(methodName){ ... }; setAttributes(Object.prototype, "__resolve", false, null, null);
The following example creates three constants on a Constants object and makes them permanent and read-only:
Constants.KILO = 1000; setAttributes(Constants, "KILO", null, true, true); Constants.MEGA = 1000*Constants.KILO; setAttributes(Constants, "MEGA", null, true, true); Constants.GIGA = 1000*Constants.MEGA; setAttributes(Constants, "GIGA", null, true, true);

setInterval()

setInterval(function, interval[, p1, ..., pN]) setInterval(object.method, interval[, p1, ..., pN])
5
Calls a function or method at a specified time interval until the clearInterval() method is called. This method allows a server-side script to run a routine. The
clearInterval() method to stop the routine.
setInterval() method returns a unique ID that you can pass to the
Note: Standard JavaScript supports an additional usage for the setInterval() method,
setInterval(stringToEvaluate, timeInterval), which is not supported by Server-Side ActionScript.
Availability
Flash Communication Server 1
Parameters
function A Function object.
object.method A method to call on object.
interval A number indicating the time in milliseconds between calls to function.
p1, ..., pN Optional parameters passed to function.
Returns
An integer that provides a unique ID for this call. If the interval is not set, returns -1.
Example
The following example uses an anonymous function to send the message "interval called" to the server log every second:
setInterval(function(){trace("interval called");}, 1000);
The following example also uses an anonymous function to send the message “interval called” to the server log every second, but it passes the message to the function as a parameter:
setInterval(function(s){trace(s);}, 1000, "interval called");
The following example uses a named function,
callback1()
, to send the message
"interval called"
to the server log:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
function callback1(){trace("interval called"); } setInterval(callback1, 1000);
The following example also uses a named function, callback2(), to send the message "interval called" to the server log, but it passes the message to the function as a parameter:
function callback2(s){ trace(s); } setInterval(callback2, 1000, "interval called");
The following example uses the second syntax:
var a = new Object(); a.displaying=displaying; setInterval(a.displaying, 3000);
displaying = function(){ trace("Hello World"); }
The previous example calls the displaying() method every 3 seconds and sends the message "Hello World" to the server log.
6
See also
clearInterval()

trace()

trace(expression)
Evaluates an expression and displays the value. You can use the trace() function to debug a script, to record programming notes, or to display messages while testing a file. The
trace() function is similar to the alert()
function in JavaScript.
The expression appears in the Live Log panel of the Administration Console; it is also published to the application.xx.log file located in a subdirectory of the RootInstall\logs folder. For example, if an application is called myVideoApp, the application log for the default application instance would be located here: RootInstall\logs\_defaultVHost_\myVideoApp\_definst_.
Availability
Flash Communication Server 1
Parameters
expression Any valid expression. The values in expression are converted to strings if possible.

Application class

Every instance of a Adobe Media Server application has an Application object, which is a single instance of the Application class. You don’t need to use a constructor function to create an Application object; it is created automatically when an application is instantiated by the server.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Use the Application object to accept and reject client connection attempts, to register and unregister classes and proxies, and to manage the life cycle of an application. The Application object has callback functions that are invoked when an application starts and stops and when a client connects and disconnects.
Availability
Flash Communication Server 1
Property summary
Property Description
7
application.allowDebug A boolean value that lets administrators access an application with the Administration API
application.clients Read-only; an Array object containing a list of all the clients connected to an application.
application.config Provides access to properties of the ApplicationObject element in the Application.xml
application.hostname Read-only; the host name of the server for default virtual hosts; the virtual host name for all other
application.name Read-only; the name of the application instance.
application.server Read-only; the platform and version of the server.
approveDebugSession() method (true) or not (false).
configuration file.
virtual hosts.
Method summary
Method Description
application.acceptConnection() Accepts a connection call from a client to the server.
application.broadcastMsg() Broadcasts a message to all clients connected to an application instance.
application.clearSharedObjects() Deletes persistent shared objects files (FSO files) specified by the soPath parameter and
application.clearStreams() Clears recorded streams files associated with an application instance.
application.denyPeerLookup() Specifies to the server that a peer lookup request has been denied.
application.disconnect() Terminates a client connection to the application.
clears all properties from active shared objects (persistent and nonpersistent).
application.gc() Invokes the garbage collector to reclaim any unused resources for this application instance.
application.getStats() Returns statistics about an application.
application.redirectConnection() Rejects a connection and provides a redirect URL.
application.registerClass() Registers a constructor function that is used when deserializing an object of a certain class
application.registerProxy() Maps a method call to another function.
application.rejectConnection() Rejects the connection call from a client to the server.
application.sendPeerRedirect() When a peer issues a lookup for a target peer, this method sends the peer an Array of
application.shutdown() Unloads the application instance.
type.
addresses for the target peer.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Event handler summary
Event handler Description
application.onAppStart() Invoked when the server loads an application instance.
application.onAppStop() Invoked when the server is about to unload an application instance.
application.onConnect() Invoked when NetConnection.connect() is called from the client.
8
application.onConnectAccept() Invoked when a client successfully connects to an application; for use with version 2
application.onConnectReject() Invoked when a connection is rejected in an application that contains components.
application.onDisconnect() Invoked when a client disconnects from an application.
application.onPeerLookup() Invoked when the server receives a lookup request.
application.onPublish() Invoked when a client publishes a stream to an application.
application.onStatus() Invoked when the server encounters an error while processing a message that was targeted
application.onUnpublish() Invoked when a client stops publishing a stream to an application.
components only.
at this application instance.

application.acceptConnection()

application.acceptConnection(clientObj)
Accepts a connection call from a client to the server.
Availability
Flash Communication Server 1
Parameters
clientObj A Client object; a client to accept.
Details
When NetConnection.connect() is called from the client side, it passes a Client object to
application.onConnect() on the server. Call application.acceptConnection() in an application.onConnect() event handler to accept a connection from a client. When this method is called, NetConnection.onStatus() is invoked on the client with the info.code property set to "NetConnection.Connect.Success".
You can use the application.acceptConnection() method outside an application.onConnect() event handler to accept a client connection that had been placed in a pending state (for example, to verify a user name and password).
When you call this method, NetConnection.onStatus() is invoked on the client with the info.code property set
"NetConnection.Connect.Success". For more information, see the NetStatusEvent.info property in the
to ActionScript 3.0 Language and Components Reference or the
NetConnection.onStatus() entry in the Adobe Media
Server ActionScript 2.0 Language Reference.
Note: When you use version 2 components, the last line (in order of execution) of the onConnect() handler should be
application.acceptConnection() or application.rejectConnection() (unless you’re leaving the
either application in a pending state). Also, any logic that follows placed in the
application.onConnectAccept() and application.onConnectReject() handlers, or it will be
acceptConnection() or rejectConnection() must be
ignored.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
The following server-side code accepts a client connection and traces the client ID:
application.onConnect = function(client){ // Accept the connection. application.acceptConnection(client); trace("connect: " + client.id); };
Note: This example shows code from an application that does not use components.

application.allowDebug

application.allowDebug
A boolean value that lets administrators access an application with the Administration API approveDebugSession() method ( streams in the Administration Console.
The default value for this property is false and is set in the Application.xml file:
<Application> ... <Debug> <AllowDebugDefault>false</AllowDebugDefault> </Debug> ... </Application>
true) or not (false). A debug connection lets administrators view information about shared objects and
9
Setting application.allowDebug to true in a server-side script overrides the value in the Application.xml file. To view information in the Administration Console about the shared objects and streams in an application, add the following line to your code:
application.allowDebug = true;
Availability
Flash Media Server 2

application.broadcastMsg()

application.broadcastMsg(cmd [, p1,..., pN])
Broadcasts a message to all clients connected to an application instance. To handle the message, the client must define a handler on the NetConnection object with the same name as the
In ActionScript 2.0, define the method on the NetConnection object. In ActionScript 3.0, assign the
NetConnection.client property to an object on which callback methods are invoked. Define the method on that
object.
Availability
Flash Media Server 2
Parameters
cmd A string; the name of the a handler on the client-side NetConnection object.
cmd parameter.
p1,..., pN A string; messages to broadcast.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
The following server-side code sends a message to the client:
application.broadcastMsg("serverMessage", "Hello Client");
The following client-side ActionScript 2.0 code handles the message and outputs “Hello Client”:
nc = new NetConnection(); nc.serverMessage = function(msg){ trace(msg); };
The following client-side ActionScript 3.0 code handles the message and outputs “Hello Client”:
var nc:NetConnection = new NetConnection() var ncClient = new Object(); nc.client = ncClient; ncClient.serverMessage = nc_serverMessage; function nc_serverMessage(msg:String):void{
trace(msg);
}

application.clearSharedObjects()

application.clearSharedObjects(soPath)
10
Deletes persistent shared objects files (FSO files) specified by the soPath parameter and clears all properties from active shared objects (persistent and nonpersistent). Even if you have deleted all the properties from a persistent shared object, unless you call
clearSharedObjects(), the FSO file still exists on the server.
Availability
Flash Communication Server 1
Parameters
soPath A string indicating the Uniform Resource Identifier (URI) of a shared object.
The soPath parameter specifies the name of a shared object, which can include a slash (/) as a delimiter between directories in the path. The last element in the path can contain wildcard patterns (for example, a question mark [?] and an asterisk [*]) or a shared object name. The
application.clearSharedObjects() method traverses the shared
object hierarchy along the specified path and clears all the shared objects. Specifying a slash (/) clears all the shared objects that are associated with an application instance.
If soPath matches a shared object that is currently active, all its properties are deleted, and a clear event is sent to all subscribers of the shared object. If it is a persistent shared object, the persistent store is also cleared.
The following values are possible for the soPath parameter:
/ clears all local and persistent shared objects associated with the instance.
/foo/bar clears the shared object /foo/bar; if bar is a directory name, no shared objects are deleted.
/foo/bar/* clears all shared objects stored under the instance directory /foo/bar. If no persistent shared objects
are in use within this namespace, the bar directory is also deleted.
/foo/bar/XX?? clears all shared objects that begin with XX, followed by any two characters. If a directory name
matches this specification, all the shared objects within this directory are cleared.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value of true if the shared object at the specified path was deleted; otherwise, false. If wildcard characters are used to delete multiple files, the method returns were successfully deleted; otherwise, it returns
true only if all the shared objects that match the wildcard pattern
false.
Example
The following example clears all the shared objects for an instance:
function onApplicationStop(){ application.clearSharedObjects("/"); }

application.clearStreams()

application.clearStreams(streamPath)
Clears recorded streams files associated with an application instance. You can use this method to clear a single stream, all streams associated with the application instance, just those streams in a specific subdirectory of the application instance, or just those streams whose names match a specified wildcard pattern.
If the clearStreams() method is invoked on a stream that is currently recording, the recorded file is set to length 0 (cleared), and the internal cached data is also cleared.
11
A call to application.clearStreams() invokes the Stream.onStatus() handler and passes it an information object that contains information about the success or failure of the call.
Note: You can also use the Administration API removeApp() method to delete all the resources for a single application instance.
Availability
Flash Communication Server 1
Parameters
streamPath A string indicating the Uniform Resource Identifier (URI) of a stream.
The streamPath parameter specifies the location and name of a stream relative to the directory of the application instance. You can include a slash (/) as a delimiter between directories in the path. The last element in the path can contain wildcard patterns (for example, a question mark [?] and an asterisk [*]) or a stream name. The
clearStreams() method traverses the stream hierarchy along the specified path and clears all the recorded streams
that match the given wildcard pattern. Specifying a slash clears all the streams that are associated with an application instance.
To clear FLV, F4V, or MP3 files, precede the stream path with flv:, mp4:, or mp3:. When you specify flv: or mp3: you don’t have to specify a file extension; .flv and .mp3 are implied. However, when you call
application.clearStreams("mp4:foo"), the server deletes any file with the name “foo” in an MPEG-4 container;
for example, foo.mp4, foo.mov, and foo.f4v. To delete a specific file, pass the file extension in the call; for example,
application.clearStreams("mp4:foo.f4v").
Note: If you don't precede the stream path with a file type, only FLV files are deleted.
The following examples show some possible values for the streamPath parameter:
flv:/ clears all FLV streams associated with the application instance.
mp3:/ clears all MP3 files associated with the application instance.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
mp4:/ clears all F4V streams associated with the application instance (for example, foo.mp4, foo.f4v, and so on).
mp4:foo.mp4 clears the foo.mp4 file.
mp4:foo.mov clears the foo.mov file.
mp3:/mozart/requiem clears the MP3 file named requiem.mp3 from the application instance’s /mozart
subdirectory.
mp3:/mozart/* clears all MP3 files from the application instance’s /mozart subdirectory.
/report clears the report.flv stream file from the application instance directory.
/presentations/intro clears the recorded intro.flv stream file from the application instance’s /presentations
subdirectory; if
intro is a directory name, no streams are deleted.
/presentations/* clears all FLV files from the application instance’s /presentations subdirectory. The
/presentation subdirectory is also deleted if no streams are used in this namespace.
/presentations/report?? clears all FLV files that begin with “report,” followed by any two characters. If there
are directories within the given directory listing, the directories are cleared of any streams that match
report??.
Returns
A boolean value of true if the stream at the specified path was deleted; otherwise, false. If wildcard characters are used to clear multiple stream files, the method returns successfully deleted; otherwise, it returns
false.
true only if all the streams that match the wildcard pattern were
12
Example
The following example clears all recorded streams:
function onApplicationStop(){ application.clearStreams("/"); }
The following example clears all MP3 files from the application instance’s /disco subdirectory:
function onApplicationStop(){ application.clearStreams("mp3:/disco/*"); }
Removing all HDS segments
To remove all the existing HDS segments when the application unloads, you can use the clearOnAppStop tag as shown below:
<JSEngine> <ApplicationObject>
<config>
<clearOnAppStop>true</clearOnAppStop></config>
</ApplicationObject>
</JSEngine>

application.clients

application.clients
Read-only; an Array object containing a list of all the clients connected to an application. Each element in the array is a reference to the Client object; use the
application.clients.length property to determine the number of users
connected to an application.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Do not use the index value of the clients array to identify users between calls, because the array is compacted when users disconnect and the slots are reused by other Client objects.
Availability
Flash Communication Server 1
Example
The following example uses a for loop to iterate through each element in the application.clients array and calls
serverUpdate() method on each client:
the
for (i = 0; i < application.clients.length; i++){ application.clients[i].call("serverUpdate"); }

application.config

application.config
Provides access to properties of the ApplicationObject element in the Application.xml configuration file. To access properties that you set in the configuration file, use the
password element, use the code application.config.password.
of the
application.config property. For example, to set the value
13
Availability
Flash Media Server 2
Example
Use this sample section from an Application.xml file for this example:
<Application> <ScriptEngine> <ApplicationObject> <config> <user_name>jdoe</user_name> <dept_name>engineering</dept_name> </config> </ApplicationObject> </ScriptEngine> </Application>
Note: You must use the <ScriptEngine> tag as <JSEngine> tag is deprecated.
The following lines of code access the user_name and dept_name properties:
trace("I am " + application.config.user_name + " and I work in the " + application.config.dept_name + " department.");
trace("I am " + application.config["user_name"] + " and I work in the " + application.config["dept_name"] + " department.");
The following code is sent to the application log file and the Administration Console:
I am jdoe and I work in the engineering department.

application.denyPeerLookup()

application.denyPeerLookup(tag:ByteArray)
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Specifies to the server that a peer lookup request has been denied. A call to denyPeerLookup() increments the
rtmfp_lookups_deny statistic in the getServerStats()Administration API. This call also logs a message specifying
the lookup parameters.
For more information, see Filter introduction requests in the Adobe Media Server Developer’s Guide.
Availability
Flash Media Server 4.5
Parameters
tag ByteArray; The event.tag received in the lookup request.
Returns
Nothing.

application.disconnect()

application.disconnect(clientObj)
Terminates a client connection to the application. When this method is called, NetConnection.onStatus() is invoked on the client with
application.onDisconnect() handler is also invoked.
info.code set to "NetConnection.Connect.Closed". The
14
Availability
Flash Communication Server 1
Parameters
clientObj A Client object indicating the client to disconnect. The object must be a Client object from the
application.clients array.
Returns
A boolean value of true if the disconnection was successful; otherwise, false.
Example
The following example calls application.disconnect() to disconnect all users from an application instance:
function disconnectAll(){ for (i=0; i < application.clients.length; i++){ application.disconnect(application.clients[i]); } }

application.gc()

application.gc()
Invokes the garbage collector to reclaim any unused resources for this application instance.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

application.getStats()

application.getStats()
Returns statistics about an application.
Availability
Flash Communication Server 1
Returns
An Object whose properties contain statistics about the application instance. The following table describes the properties:
Property Description
bw_in Total number of kilobytes received.
bw_out Total number of kilobytes sent.
bytes_in Total number of bytes sent.
bytes_out Total number of bytes received.
Note: For billing, use the sc-bytes field in the Access log.
15
msg_in Total number of Real-Time Messaging Protocol (RTMP) messages sent.
msg_out Total number of RTMP messages received.
msg_dropped Total number of RTMP messages dropped.
server_bytes_in Total number of bytes received by the server.
server_bytes_out Total number of bytes sent by the server.
total_connects Total number of clients connected to an application instance.
total_disconnects Total number of clients who have disconnected from an application instance.
Example
The following example outputs application statistics to the Live Log panel in the Administration Console:
function testStats(){ var stats = application.getStats(); for(var prop in stats){ trace("stats." + prop + " = " + stats[prop]); } }
application.onConnect = function(client){ this.acceptConnection(client); testStats(); };

application.hostname

application.hostname
Read-only; the host name of the server for default virtual hosts; the virtual host name for all other virtual hosts.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
If an application is running on the default virtual host, and if a value is set in the ServerDomain element in the Server.xml configuration file, the element. If a value has not been set in the
application.hostname property contains the value set in the ServerDomain
ServerDomain element, the property is undefined.
If an application is running on any virtual host other than the default, the application.hostname property contains the name of the virtual host.
Availability
Flash Communication Server 1.5

application.name

application.name
Read-only; the name of the application instance.
Availability
Flash Communication Server 1
Example
The following example checks the name property against a specific string before it executes some code:
16
if (application.name == "videomail/work"){ // Insert code here. }

application.onAppStart()

application.onAppStart = function (){}
Invoked when the server first loads the application instance. Use this handler to initialize an application state. The
onAppStart() event is invoked only once during the lifetime of an application instance.
Availability
Flash Communication Server 1
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
application.onAppStart = function (){ trace ("*** sample_guestbook application start");
// Create a reference to a persistent shared object. application.entries_so = SharedObject.get("entries_so", true);
// Prevent clients from updating the shared object. application.entries_so.lock();
// Get the number of entries saved in the shared object // and save it in application.lastEntry. var maxprop = 0; var soProperties = application.entries_so.getPropertyNames(); trace("soProperties:" + soProperties); if (soProperties == null) { application.lastEntry = 0; } else { for (var prop in soProperties) { maxprop = Math.max (parseInt(prop), maxprop); trace("maxprop " + maxprop); } application.lastEntry = maxprop+1; } // Allow clients to update the shared object. application.entries_so.unlock(); trace("*** onAppStart called."); };
17

application.onAppStop()

application.onAppStop = function (info){}
Invoked when the server is about to unload an application instance. You can use onAppStop() to flush the application state or to prevent the application from being unloaded.
Define a function that is executed when the event handler is invoked. If the function returns true, the application is unloaded. If the function returns handler, or if the return value is not a boolean value, the application is unloaded when the event is invoked.
The Adobe Media Server application passes an information object to the application.onAppStop() event. You can use Server-Side ActionScript to look at this information object to decide what to do in the function you define. You can also use the
application.onAppStop() event to notify users before shutdown.
If you use the Administration Console or the Server Administration API to unload a Adobe Media Server application,
application.onAppStop() is not invoked. Therefore you cannot use application.onAppStop() to tell users that
the application is exiting.
When an application doesn’t have incoming client connections, the server considers the application idle and unloads it. To prevent this, define an
Availability
Flash Communication Server 1
false, the application is not unloaded. If you don’t define a function for this event
Application.onAppStop() handler that returns false.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Parameters
info An Object, called an information object, with properties that explain why the application is about to stop
running. The information object has a
Code property Level property Description
Application.Shutdown status The application instance is about to shut down.
Application.GC status The application instance is about to be destroyed by the server.
code property and a level property.
Returns
The value returned by the function you define, if any, or null. To unload the application, return true or any non-
false value. To refuse to unload the application, return false.
Example
The following example flushes the entries_so shared object when the application stops:
application.onAppStop = function (info){ trace("*** onAppStop called."); if (info=="Application.Shutdown"){ application.entries_so.flush(); } }
18

application.onConnect()

application.onConnect = function (clientObj [, p1, ..., pN]){}
Invoked when NetConnection.connect() is called from the client. This handler is passed a Client object representing the connecting client. Use the Client object to perform actions on the client in the handler. For example, use this function to accept, reject, or redirect a client connection, perform authentication, define methods on the Client object to be called remotely from
Client.writeAccess properties to determine client access rights to server-side objects.
When performing authentication, all of the information required for authentication should be sent from the
NetConnection.connect() method to the onConnect() handler as parameters (p1..., pN).
If you don’t define an onConnect() handler, connections are accepted by default.
If there are several simultaneous connection requests for an application, the server serializes the requests so that only
application.onConnect() handler is executed at a time. It’s a good idea to write code for the
one
application.onConnect() function that is executed quickly to prevent a long connection time for clients.
Note: When you are using the version 2 component framework (that is, when you are loading the components.asc file in your server-side script file), you must use the
Availability
Flash Communication Server 1
Parameters
clientObj A Client object. This object contains information about the client that is connecting to the application.
NetConnection.call(), and set the Client.readAccess and
application.onConnectAccept() method to accept client connections.
p1 ..., pN Optional parameters passed to the application.onConnect() handler from the client-side NetConnection.connect() method when a client connects to the application.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value; true causes the server to accept the connection; false causes the server to reject the connection.
When true is returned, NetConnection.onStatus() is invoked on the client with info.code set to
"NetConnection.Connect.Success". When false is returned, NetConnection.onStatus() is invoked on the
client with
info.code set to "NetConnection.Connect.Rejected".
If null or no value is returned, the server puts the client in a pending state and the client can’t receive or send messages. If the client is put in a pending state, you must call
application.rejectConnection() at a later time to accept or reject the connection. For example, you can perform
external authentication by making a NetConnection call in your application server and having the reply handler call
application.rejectConnection(), depending on the information received by the reply handler.
application.acceptConnection() or
application.onConnect() event handler to an
application.acceptConnection() or
You can also call application.acceptConnection() or application.rejectConnection() in the
application.onConnect() event handler. If you do, any value returned by the function is ignored.
Note: Returning 1 or 0 is not the same as returning true or false. The values 1 and 0 are treated the same as any other integers and do not accept or reject a connection.
19
NetConnection.connect()
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Success
application.acceptConnection()
application.onConnect(clientObject)
return true
or call
return false
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Rejected
application.rejectConnection()
or call
return null
or don’t return a value
places application in a pending state
A. Client-side ActionScript B. Server-Side ActionScript
A
B
Example
The following examples show three ways to accept or reject a connection in the onConnect() handler:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
(Usage 1) application.onConnect = function (clientObj [, p1, ..., pN]){ // Insert code here to call methods that do authentication. // Returning null puts the client in a pending state. return null; }; (Usage 2) application.onConnect = function (clientObj [, p1, ..., pN]){ // Insert code here to call methods that do authentication. // The following code accepts the connection: application.acceptConnection(clientObj); }; (Usage 3) application.onConnect = function (clientObj [, p1, ..., pN]) { // Insert code here to call methods that do authentication. // The following code accepts the connection by returning true: return true; };
The following example verifies that the user has sent the password “XXXX”. If the password is sent, the user’s access rights are modified and the user can complete the connection. In this case, the user can create or write to streams and shared objects in the user’s own directory and can read or view any shared object or stream in this application instance.
20
// This code should be placed in the global scope.
application.onConnect = function (newClient, userName, password){ // Do all the application-specific connect logic. if (password == "XXXX"){ newClient.writeAccess = "/" + userName; this.acceptConnection(newClient); } else { var err = new Object(); err.message = "Invalid password"; this.rejectConnection(newClient, err); } };
If the password is incorrect, the user is rejected and an information object with a message property set to "Invalid
password" is returned to the client side. The object is assigned to infoObject.application. To access the message
property, use the following code on the client side:
ClientCom.onStatus = function (info.application.message){ trace(info.application.message); // Prints "Invalid password" // in the Output panel on the client side. };

application.onConnectAccept()

application.onConnectAccept = function (clientObj [,p1, ..., pN]){}
Invoked when a client successfully connects to an application; for use with version 2 components only. Use
onConnectAccept() to handle the result of an accepted connection in an application that contains components.
Note: This component set is deprecated and not included with Adobe Media Server versions 4.0 and later. The components are available from
www.adobe.com/go/ams_tools.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
If you don’t use the version 2 components framework (ActionScript 2.0 components), you can execute code in the
application.onConnect() handler after accepting or rejecting the connection. When you use the components
framework, however, any code that you want to execute after the connection is accepted or rejected must be placed in
application.onConnectAccept() and application.onConnectReject() event handlers. This architecture
the allows all of the components to decide whether a connection is accepted or rejected.
Availability
Flash Media Server (with version 2 media components only).
Parameters
clientObj A Client object; the client connecting to the application.
p1, ..., pN Optional parameters passed to the application.onConnectAccept() method. These parameters are
passed from the client-side
NetConnection.connect() method when a client connects to the application; they can
be any ActionScript data type.
Example
The following example is client-side code:
nc = new NetConnection(); nc.connect("rtmp:/test","jlopes");
nc.onStatus = function(info) { trace(info.code); };
nc.doSomething = function(){ trace("doSomething called!"); }
21
The following example is server-side code:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
// When using components, always load components.asc. load("components.asc");
application.onConnect = function(client, username){ trace("onConnect called"); gFrameworkFC.getClientGlobals(client).username = username; if (username == "hacker") { application.rejectConnection(client); } else { application.acceptConnection(client); } }
// Code is in onConnectAccept and onConnectReject statements // because components are used. application.onConnectAccept = function(client, username){ trace("Connection accepted for "+username); client.call("doSomething",null); }
application.onConnectReject = function(client, username){ trace("Connection rejected for "+username); }
22

application.onConnectReject()

application.onConnectReject = function (clientObj [,p1, ..., pN]){}
Invoked when a connection is rejected in an application that contains components.
Note: This component set is deprecated and not included with Flash Media Server versions 4.0 and later. The components are available from
If you don’t use the version 2 components framework, you can execute code in the application.onConnect() handler after accepting or rejecting a connection. When you use the components framework, however, any code that you want to execute after the connection is accepted or rejected must be placed in the
application.onConnectAccept() and application.onConnectReject() framework event handlers. This
architecture allows all of the components to decide whether a connection is accepted or rejected.
Availability
Flash Media Server (with version 2 components only)
Parameters
clientObj A Client object; the client connecting to the application.
p1, ..., pN Optional parameters passed to the application.onConnectReject() handler. These parameters are
passed from the client-side
Example
The following example is client-side code that you can use for an application:
www.adobe.com/go/ams_tools.
NetConnection.connect() method when a client connects to the application.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
nc = new NetConnection(); nc.connect("rtmp:/test","jlopes");
nc.onStatus = function(info) { trace(info.code); };
nc.doSomething = function(){ trace("doSomething called!"); }
The following example is server-side code that you can include in the main.asc file:
// When using components, always load components.asc. load( "components.asc" );
application.onConnect = function(client, username){ trace("onConnect called"); gFrameworkFC.getClientGlobals(client).username = username; if (username == "hacker") { application.rejectConnection(client); } else { application.acceptConnection(client); } }
application.onConnectAccept = function(client, username){ trace("Connection accepted for "+username); client.call("doSomething",null); }
application.onConnectReject = function(client, username){ trace("Connection rejected for "+username); }
23

application.onDisconnect()

application.onDisconnect = function (clientObj){}
Invoked when a client disconnects from an application. Use this event handler to flush any client state information or to notify other users that a user is leaving the application. This handler is optional.
Note: After a client has disconnected from an application, you cannot use this method to send data back to that disconnected client.
Availability
Flash Communication Server 1
Parameters
clientObj A Client object; a client disconnecting from the application.
Returns
Server ignores any return value.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
This example notifies all connected clients when a client disconnects from an application. The client-side FLA file contains an input text field called
connectButton. The user enters their name in the input text field. The client-side code passes the name to the server
NetConnection.connect() call, as follows:
in the
nc = new NetConnection(); nc.userDisconnects = function(name) {
statusText.text = name + ": disconnected"; } nc.onStatus = function(info){
statusText.text = info.code; } connectButton.onPress = function() {
nc.connect("rtmp://localhost/testapp", nameText.text); };
nameText, a dynamic text field called statusText, and a button called
The server-side onConnect() handler receives the user name from the client-side code and assigns it to a property of the Client object. The server passes the Client object to the the application. The
Client.call() method inside the onDisconnect() handler calls the userDisconnects
onDisconnect() handler when a client disconnects from
method on the client and passes it the name of the disconnecting client. The client displays the name of the disconnected user.
24
application.onConnect = function(client, name){
client.name = name;
trace(client.name + ": onConnect");
return true; } application.onDisconnect = function(client){ for (var i = 0; i < application.clients.length; i++){ application.clients[i].call("userDisconnects", null, client.name); }
trace(client.name + ": onDisconnect"); }
Note: To pass optional parameters to the Client.call() method, pass null for the second (responseObject) parameter.

application.onPeerLookup()

application.onPeerLookup = function (event:Object){}
Invoked when Adobe Media Server receives a request from a client to connect to another peer. The initiating peer is the peer that makes the request. The target peer is the peer to which the initiating peer wants to connect. Both the initiating peer and the target peer can be connected directly to the server or remote. To reply to the peer lookup request, call
Availability
Flash Media Server 4.5
application.sendPeerRedirect().
Parameters
event Object; contains information about the intiating peer and the target peer. Pass the event object in calls to application.sendPeerRedirect(). Pass the event.tag object in calls to Client.introducePeer().
The event object contains the following properties:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Property Data type Description
25
targetPeerID String The peerID of the target peer. The initiating peer is attempting to
initiatorAddress String The IP address of the initiating client. Send redirect information to
tag ByteArray A value that uniquely identifies this lookup request.
interfaceID Number Identifies the RTMFP interface on which the request was received.
look up and connect to the target peer.
this address.
Example
For an example of distributing peer lookup requests across multiple servers, see Distribute peer lookup requests across
multiple servers.
See also
application.sendPeerRedirect(), Client.introducePeer()

application.onPublish()

application.onPublish = function (clientObj, streamObj){}
Invoked when a client publishes a stream to an application. Use this event handler to send traffic to other servers when you’re building a large-scale live broadcasting application; this is called multipoint publishing. For example, you can support subscribers in multiple geographic locations by sending traffic from the origin server (Server A) in one city to two origin servers in two different cities (Server B and Server C). The following is the workflow for such a scenario:
1 A client publisher connects to Server A and starts publishing.
2 Server A receives notifications from the event handler application.onPublish() in a server-side script.
3 Inside the onPublish() handler, create two NetStream objects to Server B and Server C.
4 Call the NetStream.publish() method to redirect the publishing data from Server A to Server B and Server C.
5 Subscribers connecting to Server B and Server C get the same live stream.
In this example, the publishing client connects and publishes only to Server A. The rest of the data flow is handled by logic in the server-side script.
Note: You cannot change Client object properties in this handler.
Availability
Flash Media Server 3
Parameters
clientObj A Client object; the client publishing the stream to the application.
streamObj A Stream object; the stream being published to the application.
Returns
Server ignores any return value.

application.onStatus()

application.onStatus = function (infoObject){}
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Invoked when the server encounters an error while processing a message that was targeted at this application instance.
application.onStatus() handler handles any Stream.onStatus() or NetConnection.onStatus()
The messages that don’t find handlers. Also, there are a few status calls that come only to
application.onStatus().
Availability
Flash Communication Server 1
Parameters
infoObject An Object with code and level properties that contain information about the status of an application.
Some information objects also have
details and description properties.The following table describes the
information object property values:
Code property Level property Description
Application.Script.Error error The ActionScript engine has encountered a runtime error.
This information object also has the following properties:
filename: name of the offending ASC file.
lineno: line number where the error occurred.
linebuf: source code of the offending line.
26
Application.Script.Warning warning The ActionScript engine has encountered a runtime warning.
This information object also has the following properties:
filename: name of the offending ASC file.
lineno: line number where the error occurred.
linebuf: source code of the offending line.
Application.Resource.LowMemory warning The ActionScript engine is low on runtime memory. This provides an
opportunity for the application instance to free some resources or to take suitable action.
If the application instance runs out of memory, it is unloaded and all users are disconnected. In this state, the server does not invoke the
application.onDisconnect() event handler or the application.onAppStop() event handler.
Returns
Any value that the callback function returns.
Example
application.onStatus = function(info){ trace("code: " + info.code + " level: " + info.level); trace(info.code + " details: " + info.details); }; // Application.Script.Warning level: warning

application.onUnpublish()

application.onUnpublish = function (clientObj, streamObj){}
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Invoked when a client stops publishing a stream to an application. Use this event handler with
application.onPublish()to send traffic to other servers when you’re building a large-scale, live broadcasting
application.
Note: You cannot change Client object properties in this handler.
Availability
Flash Media Server 3
Parameters
clientObj A Client object; the client publishing the stream to the application.
streamObj A Stream object; the stream being published to the application.
Returns
Server ignores any return value.

application.redirectConnection()

application.redirectConnection(clientObj, url[, description[, errorObj]])
27
Rejects a connection and provides a redirect URL. You must write logic in the NetConnection.onStatus() handler that detects redirection and passes the new connection URL to the
NetConnection.connect() method.
When this method is called, NetConnection.onStatus() is invoked on the client and passed an information object with the following values:
Property Value
info.code "NetConnection.Connect.Rejected"
info.description The value passed in the description parameter; if no value is passed in the parameter, the default value is
info.ex.code 302
info.ex.redirect The new connection URL
info.level "Error"
"Connection failed"
Availability
Flash Media Server 3
Parameters
clientObj A Client object specifying a client to reject.
url A string specifying the new connection URL.
Note: If you omit this parameter, rejectConnection() is called instead.
description A string that lets you provide more information when a connection is redirected.
errorObj An object of any type that is sent to the client, explaining the reason for rejection. The errorObj object is
available in client-side scripts as the
NetConnection.onStatus() call when the connection is rejected.
application property of the information object that is passed to the
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
The following example is server-side code:
application.onConnect = function(clientObj, count){ var err = new Object(); err.message = "This is being rejected"; err.message2 = "This is the second message. with number description"; if (count == 1){ redirectURI = "rtmp://www.example.com/redirected/fromScript"; redirectDescription = "this is being rejected via Server Side Script."; } else if (count == 2){ redirectURI = "rtmp://www.example2.com/redirected/fromScript"; redirectDescription = "this is being rejected via Server Side Script."; } application.redirectConnection(clientObj, redirectURI, redirectDescription, err); }
The following example is client-side ActionScript 3.0 code:
var theConnection:NetConnection; var theConnection2:NetConnection; var client:Object = new Object();
function init():void{ connect_button.label = "Connect"; disconnect_button.label = "Disconnect";
connect_button.addEventListener(MouseEvent.CLICK, buttonHandler); disconnect_button.addEventListener(MouseEvent.CLICK, buttonHandler); }
function buttonHandler(event:MouseEvent){ switch (event.target){ case connect_button : doConnect(); break; case disconnect_button : disConnect(); break; } } function doConnect(){ makeConnection(theURI.text); }
function disConnect(){ theConnection.close(); }to
function makeConnection(uri:String){ if (theConnection){ theConnection.close(); } theConnection = new NetConnection(); theConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
28
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
theConnection.client = client; theConnection.connect(uri); }
function makeConnection2(uri:String){ if (theConnection2){ theConnection2.close(); } theConnection2 = new NetConnection(); theConnection2.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); theConnection2.client = client; theConnection2.connect(uri); }
function netStatusHandler(event:NetStatusEvent):void{ //Check the Redirect code and make connection to redirect URI if appropriate. try{ if (event.info.ex.code == 302){ var redirectURI:String; redirectURI = event.info.ex.redirect; if (redirectURI.charCodeAt(redirectURI.length-1) == 13){ redirectURI = redirectURI.slice(0,(redirectURI.length-1)); } makeConnection2(redirectURI); } } }
init();
29

application.registerClass()

application.registerClass(className, constructor)
Registers a constructor function that is used when deserializing an object of a certain class type. If the constructor for a class is not registered, you cannot call the deserialized object’s methods. This method is also used to unregister the constructor for a class. This is an advanced use of the server and is necessary only when sending ActionScript objects between a client and a server.
The client and the server communicate over a network connection. Therefore, if you use typed objects, each side must have the prototype of the same objects they both use. In other words, both the client-side and Server-Side ActionScript must define and declare the types of data they share so that there is a clear, reciprocal relationship between an object, method, or property on the client and the corresponding element on the server. You can call
application.registerClass() to register the object’s class type on the server side so that you can use the methods
defined in the class.
Constructor functions should be used to initialize properties and methods; they should not be used for executing server code. Constructor functions are called automatically when messages are received from the client and need to be “safe” in case they are executed by a malicious client. You shouldn’t define procedures that could result in negative situations, such as filling up the hard disk or consuming the processor.
The constructor function is called before the object’s properties are set. A class can define an onInitialize() method, which is called after the object has been initialized with all its properties. You can use this method to process data after an object is deserialized.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
If you register a class that has its prototype set to another class, you must set the prototype constructor back to the original class after setting the prototype. The second example below illustrates this point.
Note: Client-side classes must be defined as function function_name(){}, as shown in the following examples. If not defined in the correct way,
application.registerClass() does not identify the class when its instance passes from
the client to the server, and an error is returned.
Availability
Flash Communication Server 1
Parameters
className A string indicating the name of an ActionScript class.
constructor A constructor function used to create an object of a specific class type during object deserialization. The
name of the constructor function must be the same as constructor function is serialized as the object’s type. To unregister the class, pass the value
className. During object serialization, the name of the
null as the constructor
parameter. Serialization is the process of turning an object into something that you can send to another computer over the network.
Example
The following example defines a Color constructor function with properties and methods. After the application connects, the
registerClass() method is called to register a class for the objects of type Color. When a typed object
is sent from the client to the server, this class is called to create the server-side object. After the application stops, the
registerClass() method is called again and passes the value null to unregister the class.
30
function Color(){ this.red = 255; this.green = 0; this.blue = 0; } Color.prototype.getRed = function(){ return this.red; } Color.prototype.getGreen = function(){ return this.green; } Color.prototype.getBlue = function(){ return this.blue; } Color.prototype.setRed = function(value){ this.red = value; } Color.prototype.setGreen = function(value){ this.green = value; } Color.prototype.setBlue = function(value){ this.blue = value; } application.onAppStart = function(){ application.registerClass("Color", Color); }; application.onAppStop = function(){ application.registerClass("Color", null); };
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
The following example shows how to use the application.registerClass() method with the prototype property:
function A(){} function B(){}
B.prototype = new A(); // Set constructor back to that of B. B.prototype.constructor = B; // Insert code here. application.registerClass("B", B);

application.registerProxy()

application.registerProxy(methodName, proxyConnection [, proxyMethodName])
Maps a method call to another function. You can use this method to communicate between different application instances that can be on the same Adobe Media Server or on different Adobe Media Servers. Clients can execute server­side methods of any application instances to which they are connected. Server-side scripts can use this method to register methods to be proxied to other application instances on the same server or a different server. You can remove or unregister the proxy by calling this method and passing in the same behavior as never registering the method at all.
null for the proxyConnection parameter, which results
31
Availability
Flash Communication Server 1
Parameters
methodName A string indicating the name of a method. All requests to execute methodName for this application
instance are forwarded to the
proxyConnection A Client or NetConnection object. All requests to execute the remote method specified by
methodName are sent to the Client or NetConnection object specified in the proxyConnection parameter. Any result
returned is sent back to the originator of the call. To unregister or remove the proxy, provide a value of
proxyConnection object.
null for this
parameter.
proxyMethodName A string indicating the name of a method for the server to call on the object specified by the
proxyConnection parameter if proxyMethodName is different from the method specified by the methodName
parameter. This is an optional parameter.
Returns
A value that is sent back to the client that made the call.
Example
In the following example, the application.registerProxy() method is called in a function in the
application.onAppStart() event handler and is executed when the application starts. In the function block, a new
NetConnection object called then called to assign the method
myProxy is created and connected. The application.registerProxy() method is
getXyz() to the myProxy object.
application.onAppStart = function(){ var myProxy = new NetConnection(); myProxy.connect("rtmp://xyz.com/myApp"); application.registerProxy("getXyz", myProxy); };
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

application.rejectConnection()

application.rejectConnection(clientObj[, description[, errObj])
Note: The description parameter is supported in Flash Media Server 3 and later.
Rejects the connection call from a client to the server. The application.onConnect() handler is invoked when the client calls the connection. You can also make a call to an application server to authenticate the client before you accept or reject it.
Note: When you use version 2 components, the last line (in order of execution) of the onConnect() handler should be either application in a pending state). Also, any logic that follows placed in requirement exists only when you use version 2 components.
Availability
Flash Communication Server 1
Parameters
clientObj A Client object specifying a client to reject.
NetConnection.connect(). In the application.onConnect() handler, you can either accept or reject
application.acceptConnection() or application.rejectConnection() (unless you’re leaving the
acceptConnection() or rejectConnection() must be
application.onConnectAccept() and application.onConnectReject() handlers, or it is ignored. This
32
description A string that allows you to provide more information when a connection is redirected.
errObj An object of any type that is sent to the client, explaining the reason for rejection. The errObj object is
available in client-side scripts as the
NetConnection.onStatus() call when the connection is rejected.
application property of the information object that is passed to the
Example
In the following example, the client is rejected and sent an error message. This is the server-side code:
application.onConnect = function(client){ // Insert code here. var error = new Object();error.message = "Too many connections"; application.rejectConnection(client, error); };
This is the client-side code:
clientConn.onStatus = function (info){ if (info.code == "NetConnection.Connect.Rejected"){ trace(info.application.message); // Sends the message // "Too many connections" to the Output panel // on the client side. } };

application.sendPeerRedirect()

application.sendPeerRedirect(redirectAddress:Array, event:Object)
When a peer requests a lookup for a target peer, call this method to send the peer an Array of addresses for the target peer. Call this method from the
application.onPeerLookup() callback function.
See Distribute peer introductions across multiple servers.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Media Server 4.5
Parameters
redirectAddresses Array; An array of addresses, as Strings, that may be used to contact the target peer.
event Object; The event object received in the application.onPeerLookup() callback.
See also
application.onPeerLookup()

application.server

application.server
Read-only; the platform and version of the server.
Availability
Flash Communication Server 1
33
Example
The following example checks the server property against a string before executing the code in the if statement:
if (application.server == "Adobe Media Server-Windows/1.0"){ // Insert code here. }

application.shutdown()

application.shutdown()
Unloads the application instance. If the application is running in vhost or application-level scope, only the application instance is unloaded, but the core process remains running. If the application is running in instance scope, the application instance is unloaded and the core process terminates. This process is done asynchronously; the instance is unloaded when the unload sequence begins, not when the
After shutdown() is called, application.onAppStop() is called, connected clients are disconnected, and
application.onDisconnect() is called for each client. Calls made after calling shutdown() may not be executed.
Availability
Flash Media Server 2
Returns
A boolean value indicating success (true) or failure (false).
shutdown() call returns.

ByteArray class

The Server-Side ActionScript ByteArray class is identical to the client-side ByteArray class with the following exceptions:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
The following two methods are not implemented in Server-Side ActionScript:
ByteArray.inflate()
ByteArray.deflate()
Where an ActionScript 3.0 ByteArray API uses the int or uint data type, the Server-Side ActionScript ByteArray API uses the Number data type.
To see the methods and properties of the ByteArray class, see the ActionScript 3.0 Reference for the Flash Platform.

Client class

The Client class lets you handle each user, or client, connection to an Adobe Media Server application instance. The server automatically creates a Client object when a user connects to an application; the object is destroyed when the user disconnects from the application. Users have unique Client objects for each application to which they are connected. Thousands of Client objects can be active at the same time.
You can use the properties of the Client class to determine the version, platform, and IP address of each client. You can also set individual read and write permissions to various application resources such as Stream objects and shared objects. Use the methods of the Client class to set bandwidth limits and to call methods in client-side scripts.
34
When you call NetConnection.call() from a client-side ActionScript script, the method that is executed in the server-side script must be a method of the Client class. In your server-side script, you must define any method that you want to call from the client-side script. You can also call any methods that you define in the server-side script directly from the Client class instance in the server-side script.
If all instances of the Client class (each client in an application) require the same methods or properties, you can add those methods and properties to the class itself instead of adding them to each instance of a class. This process is called extending a class. To extend a class, instead of defining methods in the constructor function of the class or assigning them to individual instances of the class, you assign methods to the of the class. When you assign methods and properties to the
prototype property of the constructor function
prototype property, the methods are automatically
available to all instances of the class.
The following code shows how to assign methods and properties to an instance of a class. In the
application.onConnect() handler, the client instance clientObj is passed to the server-side script as a parameter.
You can then assign a property and method to the client instance.
application.onConnect = function(clientObj){ clientObj.birthday = myBDay; clientObj.calculateDaysUntilBirthday = function(){ // Insert code here. } };
The previous example works, but must be executed every time a client connects. If you want the same methods and properties to be available to all clients in the them to the
prototype property of the Client class.
application.clients array without defining them every time, assign
There are two steps to extending a built-in class by using the prototype property. You can write the steps in any order in your script. The following example extends the built-in Client class, so the first step is to write the function that you will assign to the
prototype property:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
// First step: write the functions.
function Client_getWritePermission(){ // The writeAccess property is already built in to the Client class. return this.writeAccess; }
function Client_createUniqueID(){ var ipStr = this.ip; // The ip property is already built in to the Client class. var uniqueID = "re123mn" // You would need to write code in the above line // that creates a unique ID for each client instance. return uniqueID; }
// Second step: assign prototype methods to the functions.
Client.prototype.getWritePermission = Client_getWritePermission; Client.prototype.createUniqueID = Client_createUniqueID;
// A good naming convention is to start all class method // names with the name of the class followed by an underscore.
35
You can also add properties to prototype, as shown in the following example:
Client.prototype.company = "Adobe";
The methods are available to any instance, so within application.onConnect(), which is passed a clientObj parameter, you can write the following code:
application.onConnect = function(clientObj){ var clientID = clientObj.createUniqueID(); var clientWritePerm = clientObj.getWritePermission(); };
Availability
Flash Communication Server 1
Property summary
Property Description
Client.agent Read-only; the version and platform of the client.
Client.audioSampleAccess Enables Flash Player to access raw, uncompressed audio data from streams in the specified folders.
Client.farAddress Read-only; the derived address from which the server sees the client connection originate.
Client.farID Read-only; a String identifying the RTMFP identity of the server.
Client.farNonce Read-only; a String unique to this client.
Client.id Read-only; a String that uniquely identifies the client.
Client.ip Read-only; a string containing the IP address of the client.
Client.nearAddress Read-only; the public address of the server that the client connected to.
Client.nearID Read-only; a String indicating the RTMFP identity of the server.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Property Description
Client.nearNonce Read-only.; a String unique to this client.
Client.pageUrl Read-only; a string containing the URL of the web page in which the client SWF file is embedded.
36
Client.potentialNearAddres ses
Client.protocol Read-only; a string indicating the protocol used by the client to connect to the server.
Client.protocolVersion Read-only; a string indicating the version of the protocol used by the client to connect to the server.
Client.readAccess A string of directories containing application resources (shared objects and streams) to which the client
Read-only; the list of all public addresses of the server.
has read access.
Client.referrer Read-only; a string containing the URL of the SWF file or the server in which this connection originated.
Client.reportedAddresses Read-only; an Array of addresses as Strings of all local addresses at which it can receive RTMFP traffic.
Client.secure Read-only; a boolean value that indicates whether this is an SSL connection (true) or not (false).
Client.uri Read-only; the URI specified by the client to connect to this application instance.
Client.videoSampleAccess Enables Flash Player to access raw, uncompressed video data from streams in the specified folders.
Client.virtualKey A virtual mapping for clients connecting to the server.
Client.writeAccess Provides write access to directories that contain application resources (such as shared objects and
streams) for this client.
Method summary
Method Description
Client.call() Executes a method on a client or on another server.
Client.checkBandwidth() Call this method from a client-side script to detect bandwidth.
Client.getBandwidthLimit() Returns the maximum bandwidth that the client or the server can use for this connection.
Client.getStats() Returns statistics for the client.
Client.introducePeer() Passes the address for an initiating peer and the tag for its introduction request targeting this client,
causing the client to open its end of a P2P connection back to the initiating peer.
Client.ping() Sends a ”ping“ message to the client and waits for a response.
Client.remoteMethod() Invoked when a client or another server calls the NetConnection.call() method.
Client.__resolve() Provides values for undefined properties.
Client.setBandwidthLimit() Sets the maximum bandwidth for this client from client to server, server to client, or both.
Event summary
Method Description
Client.onFarAddressChange() Invoked when a client's far address has changed.
Client.onGroupLeave Invoked when a client leaves a NetGroup.
Client.onGroupJoin Invoked with a client joins a NetGroup.
Client.onReportedAddressChang e()
Invoked when a client reports new addresses.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

Client.agent

clientObject.agent
Read-only; the version and platform of the client.
When a client connects to the server, the format of Client.agent is as follows:
Operating_System Flash_Player_Version
For example, if Flash Player version 9.0.45.0 is running on Windows®, the value of Client.agent is:
"WIN 9,0,45,0".
When a connection is made to another Adobe Media Server, the format of Client.agent is as follows:
Server_Name/Server_Version Operating_System/Operating_System_Build
For example, if the server version is 3.0.0 and it’s running on Windows Server® 2003, the value of Client.agent is:
"FlashCom/3.0.0 WIN/5.1.2600".
Availability
Flash Communication Server 1
37
Example
The following example checks the agent property against the string "WIN" and executes different code depending on whether they match. This code is written in an
function onConnect(newClient, name){ if (newClient.agent.indexOf("WIN") > -1){ trace ("Window user"); } else { trace ("non Window user.agent is" + newClient.agent); } }
onConnect() function:

Client.audioSampleAccess

clientObject.audioSampleAccess
Enables Flash Player to access raw, uncompressed audio data from streams in the specified folders.
Call the waveform that is currently playing. For more information, see the ActionScript 3.0 Language and Components Reference and “Accessing raw sound data” in Programming ActionScript 3.0.
Availability
Flash Media Server 3
Example
The following server-side code sets the audioSampleAccess directory to publicdomain:
SoundMixer.computeSpectrum()
method in client-side ActionScript 3.0 to read the raw sound data for a
SoundMixer.computeSpectrum()
entry in the
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
application.onConnect = function(client) {
// Anyone can play free content, which is all streams placed under the // samples/, publicdomain/ and contrib/ folders. client.readAccess = "samples;publicdomain;contrib";
// Paying customers get to watch more streams. if ( isPayingCustomer(client)) client.readAccess += "nonfree;premium";
// Content can be saved (user recorded streams) to contrib/ folder. client.writeAccess = "contrib";
// Anyone can gain access to an audio snapshot of the publicdomain/ folder. client.audioSampleAccess = "publicdomain";
// Paying customers can also get a video snapshot of the publicdomain/ folder. if (isPayingCustomer(client)) client.videoSampleAccess = "publicdomain"; }
See also
Client.videoSampleAccess
38

Client.call()

clientObject.call(methodName, [resultObj, [p1, ..., pN]])
Executes a method in client-side code or on another server. The remote method can return data to the resultObj parameter, if provided. Whether the remote agent is a client or another server, the method is called on the remote agent’s NetConnection object.
In ActionScript 2.0, define the method on the NetConnection object. In ActionScript 3.0, assign the
NetConnection.client property to an object on which callback methods are invoked. Define the method on that
object.
Availability
Flash Communication Server 1
Parameters
methodName A string indicating a remote method. The string uses the form "[objectPath/]method". For example,
the string on the client or remote server. The string
resultObj An Object. This is an optional parameter that is required when the sender expects a return value from the
client. If parameters are passed but no return value is desired, pass the value that you define. To be useful, it should have two methods that are invoked when the result arrives:
onStatus(). The resultObj.onResult() event is triggered if the invocation of the remote method is successful;
otherwise, the
"someObj/doSomething" tells the client to invoke the NetConnection.someObj.doSomething() method
"doAction" calls the doAction() method on the client or remote server.
null. The result object can be any object
onResult() and
resultObj.onStatus() event is triggered.
p1, ..., pN
object. These parameters are passed to the
Optional parameters that can be of any ActionScript type, including a reference to another ActionScript
methodName
parameter when the method is executed on the Flash client. If you
use these optional parameters, you must pass in some value for
Last updated 9/20/2013
resultObj
; if you do not want a return value, pass
null
.
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value of true if a call to methodName was successful on the client; otherwise, false.
Example
The following ActionScript 2.0 example shows a client-side script that defines a function called getNumber() that generates a random number:
nc = new NetConnection(); nc.getNumber = function(){ return (Math.random()); }; nc.connect("rtmp:/clientCall");
The following is the same code in ActionScript 3.0:
var nc:NetConnection = new NetConnection() var ncClient = new Object(); nc.client = ncClient; ncClient.getNumber = nc_getNumber; function nc_getNumber():void{
return (Math.random()); }
39
The following server-side script calls Client.call() in the application.onConnect() handler to call the
getNumber() method that was defined on the client. The server-side script also defines a function called randHander(), which is used in the Client.call() method as the resultObj parameter.
randHandler = function(){ this.onResult = function(res){ trace("Random number: " + res); } this.onStatus = function(info){ trace("Failed with code:" + info.code); } }; application.onConnect = function(clientObj){ trace("Connected"); application.acceptConnection(clientObj); clientObj.call("getNumber", new randHandler()); };
Note: This example does not work with version 2 components. For an example of calling Client.call() when using version 2 components, see
application.onConnectAccept().

Client.checkBandwidth()

clientObject.checkBandwidth()
Note: This method is not supported over RTMFP connections.
Call this method from a client-side script to detect client bandwidth. If the client is connected directly to the origin server, bandwidth detection occurs on the origin. If the client is connected to the origin server through an edge server, bandwidth detection happens at the first edge to which the client connected.
To use this method to detect client bandwidth, define onBWDone() and onBWCheck() methods in a client-side script. For more information, see the Adobe Media Server Developer Guide.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Note: If you define the checkBandwidth() function in a server-side script, the client call runs your definition instead of the definition in the core server code.
Availability
Flash Media Server 3

Client.farAddress

clientObject.farAddress
Read-only. The address from which the server sees the client connection originate. This value is different than
Client.ip because the value of Client.farAddress contains both the IP address and port number for the
connection. This property is called the far address because from the perspective of the server, the address is on the far side of the NAT or firewall.
Availability
Flash Media Server 4.5

Client.farID

clientObject.farId
40
Read-only. A String identifying the RTMFP identity of the client. This property has the same value as the ActionScript
NetConnection.nearID property. This property is meaningful only for RTMFP connections.
3.0
Availability
Flash Media Server 4

Client.farNonce

clientObject.farNonce
Read-only. A String unique to this client. This value is defined for RTMFP, RTMPE, and RTMPTE connections.
Availability
Flash Media Server 4

Client.getBandwidthLimit()

clientObject.getBandwidthLimit(iDirection)
Note: This method is not supported over RTMFP connections.
Returns the maximum bandwidth that the client or the server can use for this connection. Use the iDirection parameter to get the value for each direction of the connection. The value returned indicates bytes per second and can be changed with the Application.xml file of each application.
Client.setBandwidthLimit() method. Set the default value for a connection in the
You can call this method from a client-side script. Call the NetConnection.call() method and pass it the name of the method, a result object, and any arguments, as in the following:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
var re:Responder = new Responder(res); function res(info) { trace(info); for (var i:String in info) { trace(i + " - " + info[i]); } } nc.call("getBandwidthLimit", re, 0);
Availability
Flash Communication Server 1
Parameters
iDirection A number specifying the connection direction. The value 0 indicates a client-to-server direction; 1
indicates a server-to-client direction.
Returns
A number.
Example
The following example uses Client.getBandwidthLimit() to set the variables clientToServer and
serverToClient:
41
application.onConnect = function(newClient){ var clientToServer= newClient.getBandwidthLimit(0);var serverToClient= newClient.getBandwidthLimit(1); };

Client.getStats()

clientObject.getStats()
Returns statistics for the client.
You can call this method from a client-side script. Call the NetConnection.call() method and pass it the name of the method, a result object, and any arguments, as in the following:
var re:Responder = new Responder(res); function res(info) { trace(info); for (var i:String in info) { trace(i + " - " + info[i]); } } nc.call("getStats", re);
Availability
Flash Communication Server 1
Returns
An Object with various properties for each statistic returned. The following table describes the properties of the returned object:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Property Description
bytes_in Total number of bytes received by this application instance.
bytes_out Total number of bytes sent from this application instance.
msg_in Total number of RTMP messages received.
msg_out Total number of RTMP messages sent.
msg_dropped Total number of dropped RTMP messages.
ping_rtt Length of time the client takes to respond to a ping message.
audio_queue_msgs Current number of audio messages in the queue waiting to be delivered to the client.
video_queue_msgs Current number of video messages in the queue waiting to be delivered to the client.
so_queue_msgs Current number of shared object messages in the queue waiting to be delivered to the client.
data_queue_msgs Current number of data messages in the queue waiting to be delivered to the client.
dropped_audio_msgs Number of audio messages that were dropped.
dropped_video_msgs Number of video messages that were dropped.
audio_queue_bytes Total size of all audio messages (in bytes) in the queue waiting to be delivered to the client.
42
video_queue_bytes Total size of all video messages (in bytes) in the queue waiting to be delivered to the client.
so_queue_bytes Total size of all shared object messages (in bytes) in the queue waiting to be delivered to the client.
data_queue_bytes Total size of all data messages (in bytes) in the queue waiting to be delivered to the client.
dropped_audio_bytes Total size of all audio messages (in bytes) that were dropped.
dropped_video_bytes Total size of all video messages (in bytes) that were dropped.
bw_out Current downstream bandwidth (outbound from the server).
bw_in Current upstream bandwidth (inbound to the server) .
client_id A unique ID issued by the server for this client.
Example
The following example outputs a client’s statistics:
function testStats(client){ var stats = client.getStats(); for(var prop in stats){ trace("stats." + prop + " = " + stats[prop]); } } application.onConnect = function(client){ this.acceptConnection(client); testStats(client); };

Client.id

clientObject.id
Read-only; a string that uniquely identifies the client.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Media Server 3
Example
The following onConnect() function traces the ID of the connecting client:
application.onConnect(newClient) { trace(newClient.id); }

Client.introducePeer()

clientObject.introducePeer(initiatorAddress:String, tag:ByteArray)
Opens a peer-to-peer connection with a peer that requested a connection. The peer that requests the connection is called the initiating peer. The initiating peer requests a connection with a target peer. To open the connection, the target peer calls this method and passes the address for the initiating peer and the tag for the introduction request.
Call this method to Distribute peer introductions across multiple servers.
Availability
Flash Media Server 4.5
43
Parameters
initiator String. The address that the lookup request of the initiating peer came from.
tag ByteArray. The tag identifying the specific lookup request issued by the initiating peer. This value must be handed
back in order for the initiating peer to properly correlate and associate the connection attempt from this client to it.
Returns
Nothing.

Client.ip

clientObject.ip
Read-only; A string containing the IP address of the client.
Availability
Flash Communication Server 1
Example
The following example uses the Client.ip property to verify whether a new client has a specific IP address. The result determines which block of code runs.
application.onConnect = function(newClient, name){ if (newClient.ip == "127.0.0.1"){ // Insert code here. } else { // Insert code here. } };
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

Client.nearAddress

clientObject.nearAddress
Read-only. The public address the client connected to on the server. This address is public, it is not a behind NAT or firewall. This is essential information to generate peer redirects when distributing introductions across multiple servers. The redirect address set must contain known addresses for the target peer as well as the public server address the target peer is connected to. It is called the near address because from the perspective of the server it is on the near side of the NAT or firewall.
See Distribute peer introductions across multiple servers.
Availability
Flash Media Server 4.5

Client.nearID

nc.nearId
Read-only. A String indicating the RTMFP identity of the server to which the client is connected. This property has the same value as the ActionScript 3.0 connections.
NetConnection.farID property. This property is meaningful only for RTMFP
44
Availability
Flash Media Server 4

Client.nearNonce

nc.nearNonce
Read-only. A String unique to this client. This value appears to another server as its Client.farNonce value. This value is defined for RTMFP, RTMPE, and RTMPTE connections.
Availability
Flash Media Server 4

Client.onFarAddressChange()

client.onFarAddressChange = function(){}
Invoked when the farAddress of a client has changed. For example, a far address changes when a client transitions from a LAN to a wireless connection. RTMFP supports connection mobility so the without the connection having to disconnect and reconnect.
Use this event to store a list of client far addresses in a global registry or shared datastore to support distributed peer lookups. See
Availability
Flash Media Server 4.5
Distribute peer introductions across multiple servers.
farAddress for a client can change

Client.onGroupLeave

client.onGroupLeave = function(groupspecDigest:String){}
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Invoked when a client with an open server channel leaves a group or disconnects.
Availability
Flash Media Server 4.5
Parameters
groupspecDigest A String. The groupspec digest for the group the client is leaving.

Client.onGroupJoin

client.onGroupJoin = function(groupcontrol:GroupControl){}
Invoked when a client with an open server channel joins a group.
Availability
Flash Media Server 4.5
Parameters
groupcontrol A GroupControl object. The control object representing this Client's membership within a group..
45
Example
var groups = {};
Client.prototype.onGroupJoin = function(groupControl) { groupControl["client"] = this; // Remember the associated Client. var groupControlArray = groups[groupControl.groupspecDigest]; if (groupControlArray) { trace("Register Client in existing Group (by groupspec digest): " + groupControl.groupspecDigest + ", current Group size is: " + groupControlArray.length);
// find a random member to bootstrap with r = Math.random(); index = Math.floor(r * groupControlArray.length);
var peerGroupControl = groupControlArray[index]; groupControl.addNeighbor(peerGroupControl["client"].farID); groupControlArray.push(groupControl); } else { trace("Track client joining new Group (by groupspec digest): " + groupControl.groupspecDigest);
groupControlArray = []; groupControlArray.push(groupControl); groups[groupControl.groupspecDigest] = groupControlArray; } }
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

Client.onReportedAddressChange()

client.onReportedAddressChange = function(){}
Invoked when a client reports new addresses.
Use this event to store a list of client addresses in a global registry or shared datastore to support distributed peer lookups. See
Distribute peer introductions across multiple servers.
Availability
Flash Media Server 4.5
Example
client.onReportedAddressesChange = function() { var newReportedAddresses = this.reportedAddresses; // Now store these in a global registry or shared datastore to support distributed scripted peer lookups. // ... }

Client.pageUrl

clientObject.pageUrl
46
Read-only; A string containing the URL of the web page in which the client SWF file is embedded. If the SWF file isn’t embedded in a web page, the value is the location of the SWF file. The following code shows the two examples:
// trace.swf file is embedded in trace.html. client.pageUrl: http://www.example.com/trace.html
// trace.swf is not embedded in an html file. client.pageUrl: http://www.example.com/trace.swf
The value cannot be a local file address.
Availability
Flash Media Server 2
Example
The following example uses the Client.pageUrl property to verify whether a new client is located at a particular URL. The result determines which block of code runs.
application.onConnect = function(newClient){ if (newClient.pageUrl == "http://www.example.com/index.html"){ return true; } else { return false; } };

Client.ping()

clientObject.ping()
Sends a “ping” message to the client and waits for a response. If the client responds, the method returns true; otherwise,
false. Use this method to determine whether the client connection is still active.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Communication Server 1
Example
The following onConnect() function pings the connecting client and traces the results of the method:
application.onConnect(newClient) { if (newClient.ping()){ trace("ping successful"); } else { trace("ping failed"); } }
See also
Client.getStats()

Client.potentialNearAddresses

clientObject.potentialNearAddress
47
Read-only; the list of all public addresses of the server. The nearAddress is the public address of the interface to which the client is connected. However the
potentialNearAdresses is the list of all the public interfaces that may be used
to communicate with the server this client is connected to.
Use this property to distribute peer introductions across multiple servers. See Distribute peer introductions across
multiple servers.
Availability
Flash Media Server 4.5
Example
The following example outputs all the potential near addresses of the server the client has connected to:
function logAllPotentialNearAddresses(client) { var n = client.potentialNearAddresses.length; trace("Client has " + n + " potential near addresses (at the server-end of its connection)."); for (var i = 0; i < n; ++i) trace(" " + i + " : " + client.potentialNearAddresses[i] + "\n "); }

Client.protocol

clientObject.protocol
Read-only; A string indicating the protocol used by the client to connect to the server. This string can have one of the following values:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Protocol Description
rtmp RTMP over a persistent socket connection.
rtmpt RTMP tunneled over HTTP.
rtmps RTMP over an SSL (Secure Socket Layer) connection.
rtmpe An encrypted RTMP connection.
rtmpte An encrypted RTMP connection tunneled over HTTP.
rtmfp Real-Time Media Flow Protocol.
Availability
Flash Communication Server 1
Example
The following example checks the connection protocol used by a client upon connection to the application:
application.onConnect(clientObj){ if(clientObj.protocol == "rtmp") { trace("Client connected over RTMP"); } else if(clientOjb.protocol == "rtmpt") { trace("Client connected over RTMP tunneled over HTTP"); } }
48

Client.protocolVersion

clientObject.protocolVersion
Read-only; A string indicating the version of the protocol used by the client to connect to the server. This value matches the value in the
c-proto-ver field in the Access log.
See Fields in access logs.
Availability
Flash Media Server 4

Client.readAccess

clientObject.readAccess
Gives clients read access to directories containing shared objects and streams. You cannot specify file names, you can specify only a directory or a path to a directory (for example, "directory" or "directory/subdir/subdir2"). The directory you specify grants read access to that directory and to all its subdirectories. To give a client read access to multiple directories, list the directories in a string delimited by semicolons.
The default value is "/". This value grants read access to the directories in which the server is configured to look for streams and shared objects.
Note: Adobe recommends that you store either streams or shared objects in a directory, but not both.
A directory you specify is relative to the directory in which the server is configured to store streams or shared objects for that application instance. If you use a virtual directory or a storage directory, the that location.
readAccess value is relative to
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
By default, the server stores persistent shared objects in the rootinstalldir\applications\appname\sharedobjects\_definst_ directory.
By default, the server looks for streams for the default application instance in the directory rootinstalldir\applications\appname\streams\_definst_. For example, a client that connects to "rtmp://someamssever.com/test" looks for streams in the rootinstalldir\applications\test\streams\_definst_ directory. A client that connects to "rtmp://someamsserver.com/test/room1" looks for streams in the rootinstalldir\applications\test\streams\room1 directory.
Suppose there is a stream called "sample.f4v" in the applications\test\streams\_definst_ directory. In the server-side script, if you give
client.readAccess any value other than "/", the stream does not play.
Note: If you specify "\", the script does not run.
Suppose you copy the file sample2.f4v into the directory test/streams/_definst_/protected. In the server-side script, set
client.readAccess="protected". In the client-side script, call netstream.play("mp4:protected/sample2.f4v"). The file plays because it’s located in a directory that has read
access.
Now call netstream.play("mp4:sample.f4v"). The file does not play because the test/streams/_definst_ directory does not have read access.
49
Availability
Flash Communication Server 1
Details
To give a client read access, specify a list of directories (in URI format), delimited by semicolons. Any files or directories within a specified URI are also considered accessible. For example, if you specify
"myMedia", any files or
directories in the myMedia directory are also accessible (for example, myMedia/mp3s). Any files or directories in the myMedia/mp3s directory are also accessible, and so on.
Clients with read access to a directory that contains streams can play the streams. Clients with read access to a directory that contains shared objects can subscribe to the shared objects and receive notification of changes in the shared objects.
For streams, readAccess controls the streams that the connection can play.
For shared objects, readAccess controls whether the connection can listen to shared object changes.
To control access for a particular file, create a separate directory for the file and set readAccess to that directory.
Note: You cannot set this property in the application.onPublish() event.
Example
The following code is for an application called “amsapp”. It gives clients read access to all files in the folders mymedia/mp3s and mydata/notes. The clients also have read access to any files in subfolders of those folders.
application.onConnect = function(newClient, name){ newClient.readAccess = "mymedia/mp3s;mydata/notes"; };
Clients that connect to an instance of the application “amsapp” can play streams in the folder rootinstall/applications/amsapp/streams/instancename/mymedia/mp3s and all its subfolders. Those clients can listen for changes to shared objects in the folder rootinstall/applications/amsapp/sharedobjects/instancename/mydata/notes and all its subfolders.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

Client.referrer

clientObject.referrer
Read-only; A string containing the URL of the SWF file or the server in which this connection originated. The property is set when a SWF hosted on a web server or connects to an application on Adobe Media Server. The property is also set when one Adobe Media Server instance connects to another.
This property is not set when a SWF from a local file system running in stand-alone Flash Player version 10 or above connects to Adobe Media Server. If a SWF file is running in standalone Flash Player version 8 or 9, the property is set
file:///....
as
Availability
Flash Communication Server 1
Example
application.onConnect = function(newClient, name){ trace("New user connected to server from" + newClient.referrer); };

Client.remoteMethod()

myClient.remoteMethod = function([p1, ..., pN]){}
50
You can define methods on the Client object and call the methods from client-side code. To call methods from client­side code, call the
NetConnection.call() method and pass it the name of the method you defined. The server
searches the Client object instance for the method. If the method is found, it is invoked and the return value is sent back to the result object specified in the call to
NetConnection.call().
Availability
Flash Communication Server 1
Parameters
p1, ..., pN Optional parameters passed to the NetConnection.call() method.
Example
The following example creates a method called sum() as a property of the Client object newClient on the server side:
Client.prototype.sum = function(op1, op2){ return op1 + op2; };
You can call the server-side sum() method from a client-side call to the NetConnection.call() method:
nc = new NetConnection(); nc.connect("rtmp://myServer/myApp"); nc.call("sum", new result(), 20, 50); function result(){ this.onResult = function (retVal){ output += "sum is " + retVal; }; this.onStatus = function(errorVal){ output += errorVal.code + " error occurred"; }; }
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
You can also call the sum() method in server-side code:
newClient.sum();
The following example creates two functions that you can call from either a client-side or server-side script:
application.onConnect = function(clientObj) { // The function foo returns 8. clientObj.foo = function() {return 8;}; // The function bar is defined outside the onConnect call. clientObj.bar = application.barFunction; }; // The bar function adds the two values it is given. application.barFunction = function(v1,v2) { return (v1 + v2); };
You can call either of the two functions that were defined in the previous example (foo and bar) by using the following code in a client-side script:
c = new NetConnection(); c.call("foo"); c.call("bar", null, 1, 1);
You can call either of the two functions that were defined in the previous example (foo and bar) by using the following code in a server-side script:
51
c = new NetConnection(); c.onStatus = function(info) { if(info.code == "NetConnection.Connect.Success") { c.call("foo"); c.call("bar", null, 2, 2); } };

Client.reportedAddresses

clientObject.reportedAddresses
Read-only; an Array of Strings containing all the addresses at which a client can receive RTMFP traffic. The client can update this value multiple times over the lifetime of its RTMFP connection to the server.
There is a small time lag between when the client is connected and when it reports its IP addresses. The time lag is usually a few hundred milliseconds. When the server receives the reported addresses from the client, it gets an
Client.onReportedAddressChange() event. The reported addresses are valid only after the first
onReportedAddressChange() event.
Use this property to distribute peer introductions across multiple servers. See Distribute peer introductions across
multiple servers.
Availability
Flash Media Server 4.5
Example
The following function outputs a list of all the reported addresses for a client:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
function logReportedAddresses(client) { var n = client.reportedAddresses.length; trace("Client has reported " + n + " addresses."); for (var i = 0; i < n; ++i) trace(" " + i + ": " + client.reportedAddresses[i]); }

Client.__resolve()

Client.__resolve = function(propName){}
Provides values for undefined properties. When an undefined property of a Client object is referenced by Server-Side ActionScript code, the Client object is checked for a _ is invoked and passed the name of the undefined property. The return value of the _ the undefined property. In this way, _
resolve() can supply the values for undefined properties and make it appear
as if they are defined.
Availability
Flash Communication Server 1
Parameters
propName A string indicating the name of an undefined property.
resolve() method. If the object has a _resolve() method, it
resolve() method is the value of
52
Returns
The value of the property specified by the propName parameter.
Example
The following example defines a function that is called whenever an undefined property is referenced:
Client.prototype.__resolve = function (name) { return "Hello, world!"; }; function onConnect(newClient){ // Prints "Hello World". trace (newClient.property1); }

Client.secure

clientObject.secure
Read-only; A boolean value that indicates whether this is an SSL connection (true) or not (false).
Availability
Flash Media Server 2

Client.setBandwidthLimit()

clientObject.setBandwidthLimit(iServerToClient, iClientToServer)
Note: This method is not supported over RTMFP connections.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Sets the maximum bandwidth for this client from client to server, server to client, or both. The default value for a connection is set for each application in the exceed the bandwidth cap value specified in the Application.xml file. For more information, see
Client section of the Application.xml file. The value specified cannot
BandwidthCap in the
Adobe Media Server Configuration and Administration Guide.
You can call this method from a client-side script. Call the NetConnection.call() method and pass it the name of the method, a result object, and any arguments, as in the following:
var re:Responder = new Responder(res); function res(info) { trace(info); for (var i:String in info) { trace(i + " - " + info[i]); } } nc.call("setBandwidthLimit", re, 125000, 125000);
Availability
Flash Communication Server 1
Parameters
iServerToClient A number; the bandwidth from server to client, in bytes per second. Use 0 if you don’t want to
change the current setting.
53
iClientToServer A number; the bandwidth from client to server, in bytes per second. Use 0 if you don’t want to
change the current setting.
Example
The following example sets the bandwidth limits for each direction, based on values passed to the onConnect() function:
application.onConnect = function(newClient, serverToClient, clientToServer){ newClient.setBandwidthLimit(serverToClient, clientToServer); application.acceptConnection(newClient); }

Client.uri

clientObject.uri
Read-only; the URI specified by the client to connect to this application instance.
Availability
Flash Media Server 2
Example
The following example defines an onConnect() callback function that sends a message indicating the URI that the new client used to connect to the application:
application.onConnect = function(newClient, name){ trace("New user requested to connect to " + newClient.uri); };

Client.videoSampleAccess

clientObject.videoSampleAccess
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Enables Flash Player to access raw, uncompressed video data from streams in the specified folders.
Call the BitmapData.draw() method in client-side ActionScript 3.0 to read the raw data for a stream that is currently playing. For more information, see the
BitmapData.draw() entry in ActionScript 3.0 Language and Components
Reference.
Availability
Flash Media Server 3
Example
The following server-side code sets the videoSampleAccess directory to publicdomain for paying customers:
application.onConnect = function(client) {
// Anyone can play free content, which is all streams placed under the // samples/, publicdomain/, and contrib/ folders. client.readAccess = "samples;publicdomain;contrib";
// Paying customers get to watch more streams. if ( isPayingCustomer(client)) client.readAccess += "nonfree;premium";
// Content can be saved (user recorded streams) to the contrib/ folder. client.writeAccess = "contrib";
// Anyone can gain access to an audio snapshot of the publicdomain/ folder. client.audioSampleAccess = "publicdomain";
// Paying customers can also get a video snapshot of the publicdomain/ folder. if (isPayingCustomer(client)) client.videoSampleAccess = "publicdomain"; }
54
See also
Client.audioSampleAccess

Client.virtualKey

clientObject.virtualKey
Use this property in conjunction with the Stream.setVirtualPath() method to map stream URLs to physical locations on the server. This allows you to serve different content to different versions of Flash Player.
When a client connects, it receives a virtual key that corresponds to ranges that you set in the Vhost.xml file. You can
Client.virtualKey to change that value in a server-side script. The following is the code in the Vhost.xml file
use that you must configure:
<VirtualKeys> <!-- Create your own ranges and key values.--> <!-- You can create as many Key elements as you need.--> <Key from="WIN 7,0,19,0" to="WIN 9,0,0,0">A</Key> </VirtualKeys>
Using the previous Vhost.xml file, if a Flash Player 8 client connected to the server, its Client.virtualKey value would be
A.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Note: A legal key cannot contain the characters “*” and “:”.
Availability
Flash Media Server 2

Client.writeAccess

clientObject.writeAccess
Provides write access to directories that contain application resources (such as shared objects and streams) for this client. To give a client write access to directories that contain application resources, list directories in a string delimited by semicolons. By default, all clients have full write access, and the example, if
myMedia is specified as an access level, then any files or directories in the myMedia directory are also
accessible (for example, myMedia/myStreams). Similarly, any files or subdirectories in the myMedia/myStreams directory are also accessible, and so on.
For shared objects, writeAccess provides control over who can create and update the shared objects.
For streams, writeAccess provides control over who can publish and record a stream.
You cannot use this property to control access to a single file. To control access to a single file, create a separate directory for the file.
writeAccess property is set to slash (/). For
55
Don’t precede the stream path with a leading slash (/) on the client side.
Note: You cannot set this property in the application.onPublish() event.
Availability
Flash Communication Server 1
Example
The following example provides write access to the /myMedia/myStreams and myData/notes directories:
application.onConnect = function(newClient, name){ newClient.writeAccess = "/myMedia/myStreams;myData/notes"; application.acceptConnection(); };
The following example completely disables write access:
application.onConnect = function(clientObj){ clientObj.writeAccess = ""; return true; };
See also
Client.readAccess

File class

The File class lets applications write to the server’s file system. This is useful for storing information without using a database server, creating log files for debugging, and tracking usage. Also, a directory listing is useful for building a content list of streams or shared objects without using Flash Remoting.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
By default, a script can access files and directories only within the application directory of the hosting application. A server administrator can grant access to additional directories by specifying virtual directory mappings for File object paths. This is done in the
<FileObject> <VirtualDirectory>/videos;C:\myvideos</VirtualDirectory> <VirtualDirectory>/amsapps;C:\Program Files\ams\applications</VirtualDirectory> </FileObject>
FileObject tag in the Application.xml file, as shown in the following example:
This example specifies two additional directory mappings in addition to the default application directory. Any path that begins with /videos—for example, /videos/xyz/vacation.flv—maps to c:/myvideos/xyz/vaction.flv. Similarly, /amsapps/conference maps to c:/Program Files/ams/applications/conference. Any path that does not match a mapping resolves to the default application folder. For example, if c:/myapps/filetest is the application directory, then /streams/hello.flv maps to c:/myapps/filetest/streams/hello.flv.
Note: You can use an Application.xml file at the virtual host level or at the application level.
In addition, the following rules are enforced by the server:
File objects cannot be created by using native file path specification.
File object paths must follow the URI convention:
A slash (/) must be used as the path separator. Access is denied if a path contains a backslash (\), or if a dot (.) or two dots (..) is the only string component found between path separators.
56
Root objects cannot be renamed or deleted.
For example, if a path using a slash (/) is used to create a File object, the application folder is mapped.
Availability
Flash Media Server 2
Property summary
Property Description
File.canAppend Read-only; a boolean value indicating whether a file can be appended (true) or not (false).
File.canRead Read-only; A boolean value indicating whether a file can be read (true) or not (false).
File.canReplace Read-only; A boolean value indicating whether a file was opened in "create" mode (true) or not (false).
File.canWrite Read-only; a boolean value indicating whether a file can be written to (true) or not (false).
File.creationTime Read-only; a Date object containing the time the file was created.
File.exists Read-only; a boolean value indicating whether the file or directory exists (true) or not (false).
File.isDirectory Read-only; a boolean value indicating whether the file is a directory (true) or not (false).
File.isFile Read-only; a boolean value indicating whether the file is a regular data file (true) or not (false).
File.isOpen Read-only; a boolean value indicating whether the file has been successfully opened and is still open (true) or
This property is undefined for closed files.
false).
not (
File.lastModified Read-only; a Date object containing the time the file was last modified.
File.length Read-only; for a directory, the number of files in the directory, not counting the current directory and parent
File.mode Read-only; the mode of an open file.
directory entries; for a file, the number of bytes in the file.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Property Description
File.name Read-only; a string indicating the name of the file.
File.position The current offset in the file.
File.type Read-only; a string specifying the type of data or encoding used when a file is opened.
Method summary
Method Description
File.close() Closes the file.
File.copyTo() Copies a file to a different location or copies it to the same location with a different filename.
File.eof() Returns a boolean value indicating whether the file pointer is at the end of file (true) or not (false).
File.flush() Flushes the output buffers of a file.
File.list() If the file is a directory, lists the files in the directory.
File.mkdir() Creates a directory.
File.open() Opens a file so that you can read from it or write to it.
57
File.read() Reads the specified number of characters from a file and returns a string.
File.readAll() Reads the file after the location of the file pointer and returns an array with an element for each line of the file.
File.readByte() Reads the next byte from the file and returns the numeric value of the next byte, or -1 if the operation fails.
File.readBytes() Reads a specified number of bytes from a file into a ByteArray.
File.readln() Reads the next line from the file and returns it as a string.
File.remove() Removes the file or directory pointed to by the File object.
File.renameTo() Moves or renames a file.
File.seek() Skips a specified number of bytes and returns the new file position.
File.toString() Returns the path to the File object.
File.write() Writes data to a file.
File.writeAll() Takes an array as a parameter and calls the File.writeln() method on each element in the array.
File.writeByte() Writes a byte to a file.
File.writeBytes() Writes a specified number of bytes to a file from a ByteArray.
File.writeln() Writes data to a file and adds a platform-dependent end-of-line character after outputting the last parameter.

File constructor

fileObject = new File(name)
Creates an instance of the File class.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Parameters
name A string indicating the name of the file or directory. The name can contain only UTF-8 encoded characters; high
byte values can be encoded by using the URI character-encoding scheme. The specified name is mapped to a system path by using the mappings specified in the
name property of the object is set to an empty string, and no file operation can be performed.
FileObject section of the Application.xml file. If the path is invalid, the
Returns
A File object if successful; otherwise, null.
Example
The following code creates an instance of the File class:
var errorLog = new File("/logs/error.txt");
Note that the physical file isn’t created on the hard disk until you call File.open().

File.canAppend

fileObject.canAppend
Read only; a boolean value indicating whether a file can be appended (true) or not (false). The property is undefined for closed files.
58
Availability
Flash Media Server 2.0

File.canRead

fileObject.canRead
Read-only; A boolean value indicating whether a file can be read (true) or not (false).
Availability
Flash Media Server 2

File.canReplace

fileObject.canReplace
Read-only; A boolean value indicating whether a file was opened in "create" mode (true) or not (false). This property is undefined for closed files.
Availability
Flash Media Server 2

File.canWrite

fileObject.canWrite
Read only; a boolean value indicating whether a file can be written to (true) or not (false).
Note: If File.open() was called to open the file, the mode in which the file was opened is respected. For example, if the file was opened in read mode, you can read from the file, but you cannot write to the file.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Media Server 2

File.close()

fileObject.close()
Closes the file. This method is called automatically on an open File object when the object is out of scope.
Availability
Flash Media Server 2
Returns
A boolean value indicating whether the file was closed successfully (true) or not (false). Returns false if the file is not open.
Example
The following code closes the /path/file.txt file:
if (x.open("/path/file.txt", "read") ){ // Do something here. x.close(); }
59

File.copyTo()

fileObject.copyTo(name)
Copies a file to a different location or copies it to the same location with a different filename. This method returns
false if the source file doesn't exist or if the source file is a directory. When this method fails, it invokes the
application.onStatus() event handler to report errors.
Note: The user or process owner that the server runs under in the operating system must have adequate write permissions or the call can fail.
Availability
Flash Media Server 2
Parameters
name Specifies the name of the destination file. The name can contain only UTF-8 characters; high byte values can be
encoded by using the URI character-encoding scheme. The name specified is mapped to a system path by using the mappings specified in the Application.xml file. If the path is invalid or if the destination file doesn’t exist, the operation fails, and the method returns
Returns
A boolean value indicating whether the file is copied successfully (true) or not (false).
Example
The following code copies the file set by the myFileObj File object to the location provided by the parameter:
false.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
if (myFileObj.copyTo( "/logs/backup/hello.log")){ // Do something here. }

File.creationTime

fileObject.creationTime
Read-only; a Date object containing the time the file was created.
Availability
Flash Media Server 2

File.eof()

fileObject.eof()
Returns a boolean value indicating whether the file pointer is at the end of file (true) or not (false). If the file is closed, the method returns
Availability
Flash Media Server 2
true.
60
Returns
A boolean value.
Example
The following while statement lets you insert code that is executed until the file pointer is at the end of a file:
while (!myFileObj.eof()){ // Do something here. }

File.exists

fileObject.exists
Read-only; a boolean value indicating whether the file or directory exists (true) or not (false).
Availability
Flash Media Server 2

File.flush()

fileObject.flush()
Flushes the output buffers of a file. If the file is closed, the operation fails. When this method fails, it invokes the
application.onStatus() event handler to report errors.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value indicating whether the flush operation was successful (true) or not (false).

File.isDirectory

fileObject.isDirectory
Read-only; a boolean value indicating whether the file is a directory (true) or not (false).
A File object that represents a directory has properties that represent the files contained in the directory. These properties have the same names as the files in the directory, as shown in the following example:
myDir = new File("/some/directory"); myFileInDir = myDir.fileName; trace(myDir.isDirectory) // Outputs true.
The following example uses named property lookup to refer to files that do not have valid property names:
mySameFileInDir = myDir["fileName"]; myOtherFile = myDir["some long filename with spaces"];
Availability
Flash Media Server 2
61

File.isFile

fileObject.isFile
Read-only; a boolean value indicating whether a file is a regular data file (true) or not (false).
Availability
Flash Media Server 2

File.isOpen

fileObject.isOpen
Read-only; a boolean value indicating whether the file has been successfully opened and is still open (true) or not
false).
(
Note: Directories do not need to be opened.
Availability
Flash Media Server 2

File.lastModified

fileObject.lastModified
Read-only; a Date object containing the time the file was last modified.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

File.length

fileObject.length
Read-only; for a directory, the number of files in the directory, not counting the current directory and parent directory entries; for a file, the number of bytes in the file.
Availability
Flash Media Server 2

File.list()

fileObject.list(filter)
If the file is a directory, lists the files in the directory. Returns an array with an element for each file in the directory.
Availability
Flash Media Server 2
Parameters
filter A Function object that determines the files in the returned array.
62
If the function returns true when a file’s name is passed to it as a parameter, the file is added to the array returned by
File.list(). This parameter is optional and allows you to filter the results of the call.
Returns
An Array object.
Example
The following example returns files in the current directory that have 3-character names:
var a = x.currentDir.list(function(name){return name.length==3;});

File.mkdir()

fileObject.mkdir(newDir)
Creates a directory. The directory is created in the directory specified by fileObject. When this method fails, it invokes the
The user or process owner that the server runs under in the operating system must have adequate write permissions or the call can fail.
Note: You cannot call this method from a File object that is a file (where isFile is true). You must call this method from a File object that is a directory (where
Availability
Flash Media Server 2
application.onStatus() event handler to report errors.
isDirectory is true).
Parameters
newDir A string indicating the name of the new directory. This name is relative to the current File object instance.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value indicating success (true) or failure (false).
Example
The following example creates a logs directory in the myFileObject instance:
if (myFileObject.mkdir("logs")){ // Do something if a logs directory is created successfully. }

File.mode

fileObject.mode
Read-only; the mode of an open file. It can be different from the mode parameter that was passed to the open() method for the file if you have repeating attributes (for example, is closed, the property is
undefined.
Availability
Flash Media Server 2
"read, read") or if some attributes were ignored. If the file
63
See also

File.open()

File.name

fileObject.name
Read-only; a string indicating the name of the file. If the File object was created with an invalid path, the value is an empty string.
Availability
Flash Media Server 2
File.open()
fileObject.open(type, mode)
Opens a file so that you can read from it or write to it. First use the File constructor to create a File object and then call
open() on that object. When the open() method fails, it invokes the application.onStatus() event handler to report
errors.
Availability
Flash Media Server 2
Parameters
type A string indicating the encoding type for the file. The following types are supported (there is no default value):
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Value Description
"text" Opens the file for text access by using the default file encoding.
"binary" Opens the file for binary access.
"utf8" Opens the file for UTF-8 access.
mode A string indicating the mode in which to open the file. The following modes are valid and can be combined
(modes are case sensitive and multiple modes must be separated by commas—for example, "read,write"; there is no default value):
Value Description
"read" Opens a file for reading.
"write" Opens a file for writing.
"readWrite" Opens a file for both reading and writing.
"append" Opens a file for writing and positions the file pointer at the end of the file when you attempt to write to the file.
"create" Creates a new file if the file is not present. If a file exists, its contents are destroyed and a new file is created.
Note: If both "read" and "write" are set, "readWrite" is automatically set. The user or process owner that the server runs under in the operating system must have write permissions to use
"create", "append", "readWrite", and "write"
modes.
64
Returns
A boolean value indicating whether the file opened successfully (true) or not (false).
Example
The following client-side script creates a connection to an application called file:
var nc:NetConnection = new NetConnection(); function traceStatus(info) { trace("Level: " + info.level + " Code: " + info.code); } nc.onStatus = traceStatus; nc.connect("rtmp:/file");
The following server-side script creates a text file called log.txt and writes text to the file:
application.onConnect = function(client){ this.acceptConnection(client); var logFile = new File("log.txt"); if(!logFile.exists){ logFile.open("text", "append"); logFile.write("something", "somethingElse") } };

File.position

fileObject.position
The current offset in the file. This is the only property of the File class that can be set. Setting this property performs a seek operation on the file. The property is undefined for closed files.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Media Server 2

File.read()

fileObject.read(numChars)
Reads the specified number of characters from a file and returns a string. If the file is opened in binary mode, the operation fails. When this method fails, it invokes the
Availability
Flash Media Server 2
Parameters
numChars A number specifying the number of characters to read. If numChars specifies more bytes than are left in the
file, the method reads to the end of the file.
Returns
A string.
application.onStatus() event handler to report errors.
65
Example
The following code opens a text file in read mode and sets variables for the first 100 characters, a line, and a byte:
if (myFileObject.open("text", "read")){ strVal = myFileObject.read(100); strLine = myFileObject.readln(); strChar = myFileObject.readByte(); }

File.readAll()

fileObject.readAll()
Reads the file after the location of the file pointer and returns an Array object with an element for each line of the file. If the file opened in binary mode, the operation fails. When this method fails, it invokes the
application.onStatus() event handler to report errors.
Availability
Flash Media Server 2
Returns
An Array object.

File.readByte()

fileObject.readByte()
Reads the next byte from the file and returns the numeric value of the next byte or -1if the operation fails. If the file is not opened in binary mode, the operation fails.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A number; either a positive integer or -1.

File.readBytes()

fileObject.readBytes(dest, offset, length)
Reads the number of bytes specified by the length parameter from the fileObject into the dest parameter starting
offset within dest. This method throws an EOFError if length exceeds File.length - File.position.
at the
Availability
Flash Media Server 4
Parameters
dest A ByteArray into which bytes from the fileObject are read.
offset An integer specifying an offset location within the ByteArray specified in the dest parameter. This parameter
is optional. The default value is 0.
length An integer specifying the number of bytes to read from the fileObject. This parameter is optional. The
default value is
File.length - File.position.
66
Returns
Nothing.

File.readln()

fileObject.readln()
Reads the next line from the file and returns it as a string. The line-separator characters (either \r\n on Windows or \n on Linux) are not included in the string. The character \r is skipped; \n determines the end of the line. If the file opened in binary mode, the operation fails.
The File.readln() method has a maximum character limit of around 4100 characters. To read more characters, call
File.readAll().join('').
Availability
Flash Media Server 2
Returns
A string.

File.remove()

fileObject.remove(recursive)
Removes the file or directory pointed to by the File object. When this method fails, it invokes the
application.onStatus() event handler to report errors.
Availability
Flash Media Server 2
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Parameters
recursive A boolean value specifying whether to do a recursive removal of the directory and all its contents (true),
or a nonrecursive removal of the directory contents (
fileObject is not a directory, any parameters passed to the remove() method are ignored.
false). If no value is specified, the default value is false. If
Returns
A boolean value indicating whether the file or directory was removed successfully (true) or not (false). Returns
false if the file is open, the path points to a root folder, or the directory is not empty.
Example
The following example shows the creation and removal of a file:
fileObject = new File("sharedobjects/_definst_/userIDs.fso"); fileObject.remove();

File.renameTo()

fileObject.renameTo(name)
Moves or renames a file. If the file is open or the directory points to the root directory, the operation fails. When this method fails, it invokes the
application.onStatus() event handler to report errors.
67
Availability
Flash Media Server 2
Parameters
name The new name for the file or directory. The name can contain only UTF-8-encoded characters; high byte values
can be encoded by using the URI character-encoding scheme. The specified name is mapped to a system path by using the mappings specified in the Application.xml file. If the path is invalid or the destination file doesn’t exist, the operation fails.
Returns
A boolean value indicating whether the file was successfully renamed or moved (true) or not (false).

File.seek()

fileObject.seek(numBytes)
Skips a specified number of bytes and returns the new file position. This method can accept both positive and negative parameters.
Availability
Flash Media Server 2
Parameters
numBytes A number indicating the number of bytes to move the file pointer from the current position.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
If the operation is successful, returns the current position in the file; otherwise, returns -1. If the file is closed, the operation fails and calls
application.onStatus() to report a warning. The operation returns -1 when called on a
directory.

File.toString()

fileObject.toString()
Returns the path to the File object.
Availability
Flash Media Server 2
Returns
A string.
Example
The following example outputs the path of the File object myFileObject:
trace(myFileObject.toString());
68

File.type

fileObject.type
Read-only; a string specifying the type of data or encoding used when a file is opened. The following strings are supported: opened in
"text", "utf8", and "binary". This property is undefined for directories and closed files. If the file is
"text" mode and UTF-8 BOM (Byte Order Mark) is detected, the type property is set to "utf8".
Availability
Flash Media Server 2.0
See also
File.open()

File.write()

fileObject.write(param0, param1,...paramN)
Writes data to a file. The write() method converts each parameter to a string and then writes it to the file without separators. The file contents are buffered internally. The When this method fails, it invokes the application.onStatus() event handler to report errors.
Note: The user or process owner that the server runs under in the operating system must have write permissions or this call can fail.
Availability
Flash Media Server 2
File.flush() method writes the buffer to the file on disk.
Parameters
param0, param1,...paramN Parameters to write to the file.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A boolean value indicating whether the write operation was successful (true) or not (false).
Example
The following example writes "Hello world" at the end of the myFileObject text file:
if (myFileObject.open( "text", "append") ) { myFileObject.write("Hello world"); }

File.writeAll()

fileObject.writeAll(array)
Takes an Array object as a parameter and calls the File.writeln() method on each element in the array. The file contents are buffered internally. The File.flush() method writes the buffer to the file on disk.
Note: The user or process owner that the server runs under in the operating system must have write permissions or this call can fail.
Availability
Flash Media Server 2
69
Parameters
array An Array object containing all the elements to write to the file.
Returns
A boolean value indicating whether the write operation was successful (true) or not (false).

File.writeByte()

fileObject.writeByte(number)
Writes a byte to a file. The file contents are buffered internally. The File.flush() method writes the buffer to the file on disk.
Note: The user or process owner that the server runs under in the operating system must have write permissions or this call can fail.
Availability
Flash Media Server 2
Parameters
number A number to write.
Returns
A boolean value indicating whether the write operation was successful (true) or not (false).
Example
The following example writes byte 65 to the end of the myFileObject file:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
if (myFileObject.open("text","append")) { myFileObject.writeByte(65); }

File.writeBytes()

fileObject.writeBytes(source, offset, length)
Writes length number of bytes to the fileObject from the source starting at the offset within source. This method throws an EOFError if
Availability
Flash Media Server 4
Parameters
source A ByteArray from which bytes to the fileObject are written.
offset An integer specifying an offset location within the ByteArray specifyed in the source parameter. This
parameter is optional. The default value is 0.
length An integer specifying the number of bytes to write to the fileObject. This parameter is optional. The default
value is
source.length - offset.
length exceeds source.length - offset.
70
Returns
Nothing.

File.writeln()

fileObject.writeln(param0, param1,...paramN)
Writes data to a file and adds a platform-dependent end-of-line character after outputting the last parameter. The file contents are buffered internally. The
Note: The user or process owner that the server runs under in the operating system must have write permissions or this call can fail.
Availability
Flash Media Server 2
Parameters
param0, param1,...paramN Strings to write to the file.
Returns
A boolean value indicating whether the write operation was successful (true) or not (false).
Example
The following example opens a text file for writing and writes a line:
File.flush() method writes the buffer to the file on disk.
if (fileObj.open( "text", "append") ) { fileObj.writeln("This is a line!"); }
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

GroupSpecifier class

The GroupSpecifier class is used to construct the opaque strings called “groupspecs” to pass to NetStream and NetGroup constructors. A groupspec specifies an RTMFP peer-to-peer group, including the capabilities, restrictions, and authorizations of the member using the groupspec.By default, all capabilities are disabled, and peer-to-peer connections are allowed.
Neighbors within an RTMFP group may be introduced to each other in the following ways:
Server channel automatic bootstrapping.
When clients connect over an RTMFP connection, the server bootstraps them with peers who are members of the same group. To enable automatic bootstrapping, set
Explicit peerID exchange.
Two or more peers pass their peerIDs to each other. There are any number of ways for peers to exchange peerIDs, from web services to telling each other verbally.
LAN peer discovery
Use the GroupSpecifier class for LAN peer discovery. LAN peer discovery allows a server-side RTMFP NetConnection and its NetStream and NetGroup objects to automatically locate peers and join a group on the current subnet. Peers cannot discover each other unless they’re in the same group on the same subnet of the LAN. If peers with matching groupspecs are on different subnets, no error or other event is dispatched if they fail to discover each other.
GroupSpecifier.serverChannelEnabled to true.
71
The following code shows how to enable LAN peer discovery in Server-Side ActionScript. The code would be written within an event callback function or in an RPC function.
var nc = new NetConnection(); // Protocol must be RTMFP nc.connect("rtmfp://localhost/appname"); var gs = new GroupSpecifier("discovery-test"); // Must be enabled for LAN peer discovery to work gs.ipMulticastMemberUpdatesEnabled = true; // Multicast address over which to exchange peer discovery. gs.addIPMulticastAddress("224.0.0.255:30000"); // Necessary to multicast over a NetStream. gs.multicastEnabled = true; var ns = new NetStream(nc, gs.toString());

GroupSpecifier constructor

new GroupSpecifier(name:String)
Creates a GroupSpecifier object. By default, all capabilities are disabled, and peer-to-peer connections are allowed.
Availability
Flash Media Server 4
Parameters
name A String specifying a name for the group. All members must use this name to join the group.
Returns
A GroupSpecifier object if successful. If the name parameter is missing or null, throws a JavaScript error.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Example
The following example creates a GroupSpecifier object called groupSpecifier. The group created with this object will have multicast and posting enabled. The group will also have the server channel enabled.
var groupSpecifier = new GroupSpecifier("com.example.someapp"); groupSpecifier.multicastEnabled = true; groupSpecifier.postingEnabled = true; groupSpecifier.serverChannelEnabled = true;

GroupSpecifier.addBootstrapPeer()

groupSpecifier.addBootstrapPeer(peerID)
Causes the associated NetStream or NetGroup to make an initial neighbor connection to the specified peerID.
Availability
Flash Media Server 4
Parameters
peerID A String. The peerID to which an initial neighbor connection should be made to bootstrap into the peer-to-
peer mesh.
72
Returns
Nothing.

GroupSpecifier.addIPMulticastAddress()

groupSpecifier.addIPMulticastAddress(address, port)
Causes the associated NetStream or NetGroup to join the specified IP multicast group and listen to the specified UDP port.
If the address or port has an invalid format, a runtime error is raised.
Availability
Flash Media Server 4
Parameters
address A String specifying the address of the IPv4 or IPv6 multicast group to join, optionally followed by a colon
(":") and the UDP port number. If specifying an IPv6 address and a port, the IPv6 address must be enclosed in square brackets, for example,
port A Number. The UDP port on which to receive IP multicast datagrams. If port is null, the UDP port must be
specified in address. If not null, the UDP port must not be specified in address.
Returns
Nothing.
"224.0.0.254", "224.0.0.254:30000", "ff03::ffff", "[ff03::ffff]:30000".

GroupSpecifier.authorizations()

groupSpecifier.authorizations()
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns a string that represents passwords for IP multicast publishing and for posting. Append the string to an unauthorized groupspec to enable features for which passwords have been set.
Availability
Flash Media Server 4
Parameters
None.
Returns
A String.

GroupSpecifier.encodeBootstrapPeerIDSpec()

groupSpecifier.encodeBootstrapPeerIDSpec(peerID)
Encodes and returns a string that represents a bootstrap peerID. If you append the string to a groupspec, the associated NetStream or NetGroup makes an initial neighbor connection to the specified peerID.
Availability
Flash Media Server 4
73
Parameters
peerID A String. The peerID to which an initial neighbor connection should be made to bootstrap into the peer-to-
peer mesh.
Returns
A String.

GroupSpecifier.encodeGroupspecDigest()

GroupSpecifier.encodeGroupspecDigest(groupspec:String)
A static method that encodes and returns the digest for the canonical portion of the supplied groupspec. Call this method to generate a groupspec digest to correlate Group join and leave events to a known Group.
Availability
Flash Media Server 4.5
Parameters
groupspec A String. The groupspec to encode a digest for.
Returns
The digest for the canonical portion of the supplied groupspec.

GroupSpecifier.encodeIPMulticastAddressSpec()

groupSpecifier.encodeIPMulticastAddressSpec(address, port)
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Encodes and returns a string that represents an IP multicast socket address. If you append the string to a groupspec, the associated NetStream or NetGroup joins the specified IP multicast group and listens to the specified UDP port.
Throws a JavaScript error if the address or port parameters are invalid or missing.
Availability
Flash Media Server 4
Parameters
address A String. A String specifying the address of the IPv4 or IPv6 multicast group to join, optionally followed by
a colon (":") and the UDP port number. If specifying an IPv6 address and a port, the IPv6 address must be enclosed in square brackets, for example,
port A Number. The UDP port on which to receive IP multicast datagrams. If port is null, the UDP port must be
"224.0.0.254", "224.0.0.254:30000", "ff03::ffff", "[ff03::ffff]:30000".
specified in address. If not null, the UDP port must not be specified in address.
Returns
A String.

GroupSpecifier.encodePostingAuthorization()

groupSpecifier.encodePostingAuthorization(password)
74
Encodes and returns a string that represents a posting password. When posting is password-protected, you can concatenate the string to a groupspec to enable posting.
Availability
Flash Media Server 4
Parameters
password A String. The password to encode, which must match the posting password (if set) to enable
NetGroup.post().
Returns
A String.

GroupSpecifier.encodePublishAuthorization()

groupSpecifier.encodePublishAuthorization(password)
Encodes and returns a string that represents a multicast publishing password. When multicast publishing is password­protected, you can concatenate the string to a groupspec to enable posting.
Availability
Flash Media Server 4
Parameters
password A String. The password to encode, which must match the publish password (if set) to enable
NetStream.publish().
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
A String.

GroupSpecifier.groupspecWithAuthorizations()

groupSpecifier.groupspecWithAuthorizations()
Returns the opaque groupspec string, including authorizations, that can be passed to the NetStream and NetGroup constructors.
Availability
Flash Media Server 4
Parameters
None.
Returns
A String.
75

GroupSpecifier.groupspecWithoutAuthorizations()

groupSpecifier.groupspecWithoutAuthorizations()
Returns the opaque groupspec string, without authorizations, that can be passed to the NetStream and NetGroup constructors.
Availability
Flash Media Server 4
Parameters
None.
Returns
A String.

GroupSpecifier.ipMulticastMemberUpdatesEnabled

groupSpecifier.ipMulticastMemberUpdatesEnabled
A Boolean value indicating whether or not information about group membership is exchanged on IP multicast sockets. IP multicast servers can send group membership updates to help bootstrap P2P meshes or heal partitions. Peers can send membership updates on the LAN to help bootstrap LAN P2P meshes and to inform on-LAN neighbors in global meshes that other on-LAN neighbors exist, which can improve P2P performance.
Availability
Flash Media Server 4

GroupSpecifier.makeUnique()

groupSpecifier.makeUnique()
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Adds a strong pseudorandom tag to the groupspec to make it unique. The opaque groupspec string must then be passed to other potential members of the group. To join a group, a client must use this groupspec string.
Availability
Flash Media Server 4
Parameters
None.
Returns
Nothing.

GroupSpecifier.multicastEnabled

groupSpecifier.multicastEnabled
A Boolean value specifying whether or not streaming over a NetStream is enabled for the specified group. The default value is
Availability
Flash Media Server 4
false.
76

GroupSpecifier.objectReplicationEnabled

groupSpecifier.objectReplicationEnabled
A Boolean value specifying whether or not Object Replication is enabled for the specified NetGroup. The default value
false.
is
Availability
Flash Media Server 4

GroupSpecifier.peerToPeerDisabled

groupSpecifier.peerToPeerDisabled
A Boolean value specifying whether or not peer-to-peer connections are disabled in this NetGroup or NetStream. The default value is
If peer-to-peer connections are disabled, it is guaranteed that no upstream bandwidth will be used by any member of the group because no neighbor connections will be made. If peer-to-peer connections are disabled, the peer-to-peer warning dialog is suppressed. This mode is only useful for sending and receiving multicast streams using pure IP multicast.
Availability
Flash Media Server 4
false.

GroupSpecifier.postingEnabled

groupSpecifier.postingEnabled
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
A Boolean value specifying whether or not posting is enabled for the specified NetGroup. The default value is false. For information about posting, see
NetGroup.post().
Availability
Flash Media Server 4

GroupSpecifier.routingEnabled

groupSpecifier.routingEnabled
A Boolean value specifying whether or not the directed routing methods are enabled in the specified NetGroup. The default value is
false.
Availability
Flash Media Server 4

GroupSpecifier.serverChannelEnabled

groupSpecifier.serverChannelEnabled
A Boolean value specifying whether or not members attempt to open a channel to the server for this group. The default value is
false.
77
A channel to the server must be open before the server can provide supporting functions, such as bootstrapping, to group members. Supporting functions may or may not be provided over this channel depending on server configuration.
To use the server channel for automatic bootstrapping, set the JoinLeaveEventsmode attribute to "All" in the Application.xml file.
<GroupControl>
<JoinLeaveEvents mode="All"/> </GroupControl>
Availability
Flash Media Server 4

GroupSpecifier.setPostingPassword()

groupSpecifier.setPostingPassword(password, salt)
Specifies a password that is required to call NetGroup.post().
Availability
Flash Media Server 4
Parameters
password A String. The password. If null, no password is required to post. The default value is null.
salt A String. Modifies the hash of the password to increase the difficulty of guessing it. For best security, this
parameter should be set to a random value. The default value is null.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Returns
Nothing.

GroupSpecifier.setPublishPassword()

groupSpecifier.setPublishPassword(password, salt)
Specifies a password that is required to call NetStream.publish() to multicast publish into a group.
Availability
Flash Media Server 4
Parameters
password A String. The password. If null, no password is required. The default value is null.
salt A String. Modifies the hash of the password to increase the difficulty of guessing it. For best security, this
parameter should be set to a random value. The default value is null.
Returns
Nothing.
78

GroupSpecifier.toString()

groupSpecifier.toString()
Identical to the groupspecWithAuthorizations() method. Convenience method to return the opaque groupspec string, including authorizations, to pass to NetStream and NetGroup constructors.
Availability
Flash Media Server 4
Parameters
None.
Returns
A String.

GroupControl

Flash Media Server 4.5
The GroupControl class represents an association between a remote peer and a NetGroup that it has joined.
Use the GroupControl class to distribute peer lookup requests across multiple servers.
For more information
Distribute peer introductions across servers
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

GroupControl.addNeighbor()

gc.addNeighbor(peerID:String);
Directs the remote peer to connect directly to the specified peerID, which must already be in this group, and adds it as a neighbor.
This method advises the remote peer to connect to the specified neighbor. The connection process is separate and happens only after this method is called.
Throws an error if any arguments are omitted or if arguments are the wrong type.
Available
Flash Media Server 4.5
Parameters
peerID A String. The peerID to connect to.
Returns
A Boolean value, true if the add neighbor request was dispatched to the remote peer, false otherwise.
79

GroupControl.addMemberHint()

gc.addMemberHint(peerID:String);
Directs the remote peer to add a record specifying that peerID is a member of the group. An immediate connection to it is attempted only if it is needed for the topology.
Throws an error if any arguments are omitted or if arguments are of the wrong type.
Available
Flash Media Server 4.5
Parameters
peerID A String. The peerID to add to the set of potential neighbors.
Returns
A Boolean value, true if the add member hint request was dispatched to the remote peer, false otherwise.

GroupControl.groupspecDigest

Read-only; The digest of the canonical groupspec, which securely identifies the group this client has joined.
Available
Flash Media Server 4.5
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

LoadVars class

The LoadVars class lets you send all the variables in an object to a specified URL and lets you load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all variables, which can make your application more efficient. You can use the data is loaded, and not before.
The LoadVars class works much like the XML class; it uses the load(), send(), and sendAndLoad() methods to communicate with a server. The main difference between the LoadVars class and the XML class is that LoadVars transfers ActionScript name-value pairs, rather than an XML Document Object Model (DOM) tree stored in the XML object. The LoadVars class follows the same security restrictions as the XML class.
Availability
Flash Media Server 2
Property summary
Property Description
LoadVars.onLoad() handler to ensure that your application runs when
80
LoadVars.contentType The MIME type sent to the server when you call the LoadVars.send() or LoadVars.sendAndLoad()
LoadVars.loaded A boolean value that indicates whether a LoadVars.load() or LoadVars.sendAndLoad() operation
method.
has completed (
true) or not (false).
Method summary
Method Description
LoadVars.addRequestHeader() Adds or changes HTTP request headers (such as Content-Type or SOAPAction) sent with POST
LoadVars.decode() Converts the query string to properties of the specified LoadVars object.
LoadVars.getBytesLoaded() Returns the number of bytes loaded from the last or current LoadVars.send() or
LoadVars.getBytesTotal() Returns the number of total bytes loaded during all LoadVars.send() or
LoadVars.load() Downloads variables from the specified URL, parses the variable data, and places the resulting
LoadVars.send() Sends the variables in the specified object to the specified URL.
LoadVars.sendAndLoad() Posts the variables in the specified object to the specified URL.
LoadVars.toString() Returns a string containing all enumerable variables in the specified object, in the MIME content
actions.
LoadVars.sendAndLoad() method call.
LoadVars.sendAndLoad() method calls.
variables in the LoadVars object that calls the method.
encoding application/x-www-urlform-encoded.
Event handler summary
Event handler Description
LoadVars.onData() Invoked when data has completely downloaded from the server or when an error occurs while data is
LoadVars.onHTTPStatus() Invoked when Adobe Media Server receives an HTTP status code from the server.
LoadVars.onLoad() Invoked when a LoadVars.send() or LoadVars.sendAndLoad() operation has completed.
downloading from a server.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

LoadVars constructor

new LoadVars()
Creates a LoadVars object. You can use the methods of the LoadVars object to send and load data.
Availability
Flash Media Server 2
Example
The following example creates a LoadVars object called my_lv:
var my_lv = new LoadVars();

LoadVars.addRequestHeader()

myLoadVars.addRequestHeader(header, headerValue)
Adds or changes HTTP request headers (such as Content-Type or SOAPAction) sent with POST actions. There are two possible use cases for this method: you can pass two strings, strings, alternating header names and header values.
If multiple calls are made to set the same header name, each successive value replaces the value set in the previous call.
header and headerValue, or you can pass an array of
81
Availability
Flash Media Server 2
Parameters
header A string or an array of strings that represents an HTTP request header name.
headerValue A string that represents the value associated with header.
Example
The following example adds a custom HTTP header named SOAPAction with a value of Foo to the my_lv object:
var my_lv = new LoadVars(); my_lv.addRequestHeader("SOAPAction", "'Foo'");
The following example creates an array named headers that contains two alternating HTTP headers and their associated values. The array is passed as a parameter to the
var my_lv = new LoadVars(); var headers = ["Content-Type", "text/plain", "X-ClientAppVersion", "2.0"]; my_lv.addRequestHeader(headers);
addRequestHeader() method.
The following example creates a new LoadVars object that adds a request header called FLASH-UUID. The header contains a variable that the server can check.
var my_lv = new LoadVars(); my_lv.addRequestHeader("FLASH-UUID", "41472"); my_lv.name = "Mort"; my_lv.age = 26; my_lv.send("http://flash-mx.com/mm/cgivars.cfm", "_blank", "POST");
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

LoadVars.contentType

myLoadVars.contentType
The MIME type sent to the server when you call the LoadVars.send() or LoadVars.sendAndLoad() method. The default is application/x-www-urlform-encoded.
Availability
Flash Media Server 2
Example
The following example creates a LoadVars object and displays the default content type of the data that is sent to the server:
application.onConnect = function(client){ this.acceptConnection(client); var my_lv = new LoadVars(); trace(my_lv.contentType); };
// Output to Live Log: application/x-www-form-urlencoded
82

LoadVars.decode()

myLoadVars.decode(queryString)
Converts the query string to properties of the specified LoadVars object. This method is used internally by the
LoadVars.onData() event handler. Most users do not need to call this method directly. If you override the LoadVars.onData() event handler, you can explicitly call LoadVars.decode() to parse a string of variables.
Availability
Flash Media Server 2
Parameters
queryString A URL-encoded query string containing name-value pairs.
Example
The following example traces the three variables:
application.onConnect = function(client){ this.acceptConnection(client); // Create a new LoadVars object. var my_lv = new LoadVars(); //Convert the variable string to properties. my_lv.decode("name=Mort&score=250000"); trace(my_lv.toString()); // Iterate over properties in my_lv. for (var prop in my_lv) { trace(prop+" -> "+my_lv[prop]); } };
The following is output to the Live Log panel in the Administration Console:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
name=Mort&score=250000 name -> Mort score -> 250000 contentType -> application/x-www-form-urlencoded loaded -> false

LoadVars.getBytesLoaded()

myLoadVars.getByesLoaded()
Returns the number of bytes loaded from the last or current LoadVars.load() or LoadVars.sendAndLoad() method call. The value of the
Availability
Flash Media Server 2
Returns
A number.
See also

LoadVars.getBytesTotal()

contentType property does not affect the value of getBytesLoaded().
83
LoadVars.getBytesTotal()
myLoadVars.getBytesTotal()
Returns the total number of bytes loaded into an object during allLoadVars.load() or LoadVars.sendAndLoad()
LoadVars.load() or LoadVars.sendAndLoad()method calls. Each time a call to load() or sendAndLoad() is
issued, the
getBytesLoaded() method is reset, but the getBytesTotal() method continues to grow.
The value of the contentType property does not affect the value of getBytesLoaded().
Availability
Flash Media Server 2
Returns
A number. Returns undefined if no load operation is in progress or if a load operation has not been initiated. Returns
undefined if the number of total bytes can’t be determined—for example, if the download was initiated but the server
did not transmit an HTTP content length.
See also
LoadVars.getBytesLoaded()

LoadVars.load()

myLoadVars.load(url)
Downloads variables from the specified URL, parses the variable data, and places the resulting variables into the LoadVars object that calls the method. You can load variables from a remote URL or from a URL in the local file system; the same encoding standards apply to both.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Any properties in the myLoadVars object that have the same names as downloaded variables are overwritten. The downloaded data must be in the MIME content type and be application/x-www-urlform-encoded.
The LoadVars.load() method call is asynchronous.
Availability
Flash Media Server 2
Parameters
url A string indicating the URL from which to download variables.
Returns
A boolean value indicating success (true) or failure (false).
Example
The following code defines an onLoad() handler function that signals when data is returned:
application.onConnect = function(client){ this.acceptConnection(client); var my_lv = new LoadVars(); my_lv.onLoad = function(success) { if (success) { trace(this.toString()); } else { trace("Error loading/parsing LoadVars."); } }; my_lv.load("http://www.helpexamples.com/flash/params.txt"); };
84

LoadVars.loaded

myLoadVars.loaded
A boolean value that indicates whether a LoadVars.load() or LoadVars.sendAndLoad() operation has completed
true) or not (false).
(
Availability
Flash Media Server 2
Example
The following example loads a text file and writes information to the log file when the operation is complete:
var my_lv = new LoadVars(); my_lv.onLoad = function(success) { trace("LoadVars loaded successfully: "+this.loaded); }; my_lv.load("http://www.helpexamples.com/flash/params.txt");
See also
LoadVars.onLoad()
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

LoadVars.onData()

myLoadVars.onData(src){}
Invoked when data has completely downloaded from the server or when an error occurs while data is downloading from a server.
Availability
Flash Media Server 2
Parameters
src A string or undefined; the raw (unparsed) data from a LoadVars.load() or LoadVars.sendAndLoad()
method call.
Details
This handler is invoked before the data is parsed and can be used to call a custom parsing routine instead of the one built in to Flash Player. The value of the can be either
src parameter is undefined, an error occurred while downloading the data from the server.
the
undefined or a string that contains the URL-encoded name-value pairs downloaded from the server. If
The default implementation of LoadVars.onData() invokes LoadVars.onLoad(). You can override this default implementation by assigning a custom function to you call it in your implementation of
src parameter that is passed to the function assigned to LoadVars.onData()
LoadVars.onData(), but LoadVars.onLoad() is not called unless
LoadVars.onData().
85
Example
The following example loads a text file and traces the content when the operation is complete:
var my_lv = new LoadVars(); my_lv.onData = function(src) { if (src == undefined) { trace("Error loading content."); return; } trace(src); }; my_lv.load("content.txt", my_lv, "GET");

LoadVars.onHTTPStatus()

myLoadVars.onHTTPStatus(httpStatus){}
Invoked when Adobe Media Server receives an HTTP status code from the server. This handler lets you capture and act on HTTP status codes.
Availability
Flash Media Server 2
Parameters
httpStatus A number; the HTTP status code returned by the server. For example, a value of 404 indicates that the
server has not found a match for the requested URL. HTTP status codes can be found in sections 10.4 and 10.5 of the HTTP specification. (For more information, see the W3 website at
www.w3.org.)
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Details
The onHTTPStatus() handler is invoked before onData(), which triggers calls to onLoad() with a value of
undefined if the load fails. After onHTTPStatus() is triggered, onData() is always triggered, whether or not you
override of the
onHTTPStatus() is not invoked, this indicates that Adobe Media Server did not try to make the URL request.
onHTTPStatus(). To best use the onHTTPStatus() handler, you should write a function to catch the result
onHTTPStatus() call; you can then use the result in your onData() and onLoad() handlers. If
If Adobe Media Server cannot get a status code, or if it cannot communicate with the server, the default value of 0 is passed to your ActionScript code.
Example
The following example shows how to use onHTTPStatus() to help with debugging. The example collects HTTP status codes and assigns their value and type to an instance of the LoadVars object. (Notice that this example creates the instance members
this.httpStatus and this.httpStatusType at runtime.) The onData() handler uses these
instance members to trace information about the HTTP response that can be useful in debugging.
var myLoadVars = new LoadVars();
myLoadVars.onHTTPStatus = function(httpStatus) { this.httpStatus = httpStatus; if(httpStatus < 100) { this.httpStatusType = "flashError"; } else if(httpStatus < 200) { this.httpStatusType = "informational"; } else if(httpStatus < 300) { this.httpStatusType = "successful"; } else if(httpStatus < 400) { this.httpStatusType = "redirection"; } else if(httpStatus < 500) { this.httpStatusType = "clientError"; } else if(httpStatus < 600) { this.httpStatusType = "serverError"; } }
myLoadVars.onData = function(src) { trace(">> " + this.httpStatusType + ": " + this.httpStatus); if(src != undefined) { this.decode(src); this.loaded = true; this.onLoad(true); } else { this.onLoad(false); } }
myLoadVars.onLoad = function(success) {}
myLoadVars.load("http://weblogs.macromedia.com/mxna/flashservices/getMostRecentPosts.cfm");
86
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

LoadVars.onLoad()

myLoadVars.onLoad(success){}
Invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has completed. If the variables load successfully, the response from the server, the
If the success parameter is true, the myLoadVars object is populated with variables downloaded by the
LoadVars.load() or LoadVars.sendAndLoad() operation, and these variables are available when the onLoad()
handler is invoked.
Availability
Flash Media Server 2
Parameters
success A boolean value indicating whether the LoadVars.load() operation ended in success (true) or failure
false).
(
Example
The following example creates a new LoadVars object, attempts to load variables into it from a remote URL, and prints the result:
success parameter is true. If the variables were not received, or if an error occurred in receiving the
success parameter is false.
87
myLoadVars = new LoadVars(); myLoadVars.onLoad = function(result){ trace("myLoadVars load success is " + result); } myLoadVars.load("http://www.someurl.com/somedata.txt");

LoadVars.send()

myLoadVars.send(url [, target, method])
Sends the variables in the myLoadVars object to the specified URL. All enumerable variables in the myLoadVars object are concatenated into a string that is posted to the URL by using the HTTP
The MIME content type sent in the HTTP request headers is the value of LoadVars.contentType.
Availability
Flash Media Server 2
Parameters
url A string; the URL to which to upload variables.
target A File object. If you use this optional parameter, any returned data is output to the specified File object. If this
parameter is omitted, the response is discarded.
method A string indicating the GET or POST method of the HTTP protocol. The default value is POST. This parameter
is optional.
POST method.
Returns
A boolean value indicating success (true) or failure (false).
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
See also

LoadVars.sendAndLoad()

LoadVars.sendAndLoad()
myLoadVars.sendAndLoad(url, target[, method ])
Posts the variables in the myLoadVars object to the specified URL. The server response is downloaded and parsed as variable data, and the resulting variables are placed in the
LoadVars.send(). Variables are downloaded into target in the same way as LoadVars.load().
Availability
Flash Media Server 2
Parameters
url A string; the URL to which to upload variables.
target The LoadVars object that receives the downloaded variables.
method A string; the GET or POST method of the HTTP protocol. The default value is POST. This parameter is optional.
target object. Variables are posted in the same way as
88
Returns
A boolean value indicating success (true) or failure (false).

LoadVars.toString()

myLoadVars.toString()
Returns a string containing all enumerable variables in myLoadVars, in the MIME content encoding application/x­www-form-urlencoded.
Availability
Flash Media Server 2
Returns
A string.
Example
The following example instantiates a new LoadVars() object, creates two properties, and uses toString() to return a string containing both properties in URL-encoded format:
var my_lv = new LoadVars(); my_lv.name = "Gary"; my_lv.age = 26; trace (my_lv.toString()); //output: age=26&name=Gary

Log class

The Log class lets you create a Log object that can be passed as an optional parameter to the constructor for the WebService class.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Availability
Flash Media Server 2
Event handler summary
Event handler Description
Log.onLog() Invoked when a log message is sent to a log.

Log constructor

new Log([logLevel][, logName])
Creates a Log object that can be passed as an optional parameter to the constructor for the WebService class.
Availability
Flash Media Server 2
Parameters
logLevel One of the following values (if not set explicitly, the level defaults to Log.BRIEF):
89
Value Description
Log.BRIEF Primary life cycle event and error notifications are received.
Log.VERBOSE All life cycle event and error notifications are received.
Log.DEBUG Metrics and fine-grained events and errors are received.
logName An optional parameter that can be used to distinguish between multiple logs that are running
simultaneously to the same output.
Returns
A Log object.
Example
The following example creates a new instance of the Log class:
newLog = new Log();

Log.onLog()

myLog.onLog(message){}
Invoked when a log message is sent to a log.
Availability
Flash Media Server 2
Parameters
message A log message.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

MulticastStreamInfo class

Flash Media Server 4.5
The MulticastStreamInfo class specifies various Quality of Service (QoS) statistics related to a NetStream object's underlying RTMFP peer-to-peer and IP Multicast stream transport. A MulticastStreamInfo object is returned by the
NetStream.multicastInfo property.
Properties that return numbers represent totals computed from the beginning of the multicast stream. These types of properties include the number of media bytes sent or the number of media fragment messages received. Properties that are rates represent a snapshot of the current rate averaged over a few seconds. These types of properties include the rate at which a local node is receiving data.
To see a list of values contained in the MulticastStreamInfo object, use the MulticastStreamInfo.toString() method.

MulticastStreamInfo.bytesPushedToIPMulticast

msi.bytesPushedToIPMulticast
Read-only; Specifies the the total count of media bytes sent by the local node to IP Multicast.
90

MulticastStreamInfo.bytesReceivedFromIPMulticast

msi.bytesReceivedFromIPMulticast
Read-only; Specifies the total count of media bytes received by the local node from IP Multicast.
Availability
Flash Media Server 4

MulticastStreamInfo.bytesReceivedFromServer

msi.bytesReceivedFromServer
Read-only; Specifies the total count of media bytes received by the local node from the server.
Availability
Flash Media Server 4

MulticastStreamInfo.bytesRequestedByPeers

msi.bytesRequestedByPeers
Read-only; Specifies the total count of media bytes sent by the local node to peers in response to requests from those peers for specific fragments.
Availability
Flash Media Server 4

MulticastStreamInfo.bytesRequestedFromPeers

msi.bytesRequestedFromPeers
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Read-only; Specifies the total count of media bytes received by the local node from peers that were specifically requested by the local node.
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsPushedFromPeers

msi.fragmentsPushedFromPeers
Read-only; Specifies the total count of media fragment messages received by the local node that were pushed by peers.
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsPushedToIPMulticast

msi.fragmentsPushedToIPMulticast
Read-only; Specifies the total count of media fragments sent by the local node to IP Multicast.
91
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsPushedToPeers

msi.fragmentsPushedToPeers
Read-only; Specifies the total count of media fragment messages pushed by the local node to peers.
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsReceivedFromIPMulticast

msi.fragmentsReceivedFromIPMulticast
Read-only; Specifies the total count of media fragment messages received by the local node from IP Multicast.
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsReceivedFromServer

msi.fragmentsReceivedFromServer
Read-only; Specifies the total count of media fragment messages received by the local node from the server.
Availability
Flash Media Server 4
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

MulticastStreamInfo.fragmentsRequestedByPeers

msi.fragmentsRequestedByPeers
Read-only; Specifies the total count of media fragment messages sent by the local node to peers in response to requests from those peers for specific fragments.
Availability
Flash Media Server 4

MulticastStreamInfo.fragmentsRequestedFromPeers

msi.fragmentsRequestedFromPeers
Read-only; Specifies the total count of media fragment messages received by the local node from peers that were specifically requested by the local node.
Availability
Flash Media Server 4

MulticastStreamInfo.receiveControlBytesPerSecond

msi.receiveControlBytesPerSecond
92
Read-only; Specifies the data rate of control overhead messages received by the local node from peers in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.receiveDataBytesPerSecond

msi.receiveDataBytesPerSecond
Read-only; Specifies the total rate at which media data is being received by the local node from peers, the server, and over IP multicast, in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.receiveDataBytesPerSecondFromIPMulticast

msi.receiveDataBytesPerSecondFromIPMulticast
Read-only; Specifies the rate at which media data is being received by the local node from IP Multicast in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.receiveDataBytesPerSecondFromServer

msi.receiveDataBytesPerSecondFromServer
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Read-only; Specifies the rate at which media data is being received by the local node from the server in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.sendControlBytesPerSecond

msi.sendControlBytesPerSecond
Read-only; Specifies the total data rate of control overhead messages sent by the local node to peers and the server in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.sendControlBytesPerSecondToServer

msi.sendControlBytesPerSecondToServer
Read-only; Specifies the data rate of control overhead messages sent by the local node to the server in bytes per second.
93
Availability
Flash Media Server 4

MulticastStreamInfo.sendDataBytesPerSecond

msi.sendDataBytesPerSecond
Read-only; Specifies the rate at which media data is being sent by the local node to peers in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.sendDataBytesPerSecondToIPMulticast

msi.sendDataBytesPerSecondToIPMulticast
Read-only; Specifies the rate at which media data is being sent by the local node to IP Multicast in bytes per second.
Availability
Flash Media Server 4

MulticastStreamInfo.toString()

ns.toString()
Returns a text value listing the properties of the MulticastStreamInfo object.
Availability
Flash Media Server 4
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference

MulticastStreamIngest class

Flash Media Server 4.5
Use the MulticastStreamIngest class to ingest RTMFP multicast streams and convert the multicast data units to messages that a Stream object can use. To create a MulticastStreamIngest instance, call
NetGroup.getMulticastStreamIngest(). Then call Stream.playFromGroup() to play the stream from the group.
You can also use Server-Side ActionScript to:
Record the Stream object.
Deliver the Stream object to clients over RTMP/T/S/E
Package the stream for delivery using HTTP Dynamic Streaming and HTTP Live Streaming.
For more information
Multicasting

MulticastStreamIngest.ingesting

mcsi.ingesting
94
Read-only; A Boolean property that is true if the target multicast stream is bound and currently being ingested; otherwise
Availability
Flash Media Server 4.5
false.

MulticastStreamIngest.multicastInfo

mcsi.multicastInfo
Read-only; A MulticastStreamInfo object whose properties contain statistics about the stream quality of service.
Availability
Flash Media Server 4.5

MulticastStreamIngest.multicastWindowDuration

mcsi.multicastWindowDuration
The duration, in seconds, of the peer-to-peer multicast reassembly window. The default value is 8.
Availability
Flash Media Server 4.5

MulticastStreamIngest.multicastPushNeighborLimit

mcsi.multicastPushNeighborLimit
The maximum number of peers to which to push multicast media. The default value is 4.
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Even though the script is pulling data from a group in order to transform the data, the peer is still in the group and expected to pass along the data to other members of the group. If you don’t want to pass along the data, set this value to 0.
Availability
Flash Media Server 4.5

MulticastStreamIngest.close()

mcsi.close()
Stops ingesting the source multicast stream.
Availability
Flash Media Server 4.5
Parameters
None.
Returns
None.
95

MulticastStreamIngest.onStatus()

mcsi.onStatus = function(infoObject){}
Invoked when a MulticastStreamIngest status change occurs.
Availability
Flash Media Server 4.5
Parameters
infoObject An Object with the following properties:
infoObject.code
infoObject.code.level
infoObject.fragmentsLost—a Number indicating the number of multicast data units lost.
The code and level properties provides information about the status change. All values are of type String:
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
code level Description
96
"NetStream.MulticastStream.GapNotify" "status" One or more multicast data units
"NetStream.MulticastStream.Reset" "status" This is the same as the
"NetGroup.MulticastStream.PublishNotify" "status" This is the same as the
"NetGroup.MulticastStream.UnpublishNotify" "status" This is the same as the
have been lost from the stream being ingested. The
fragmentsLost property
contains the amount that were lost.
"NetStream.MulticastStream .Reset"
event that is dispatched
by NetStream.
The multicast stream has been reset to a different stream published with the same name in the same Flash group.
"NetGroup.MulticastStream. PublishNotify"
dispatched by NetGroup.
However, this event is dispatched only for the multicast stream that is being targeted for ingest rather than for any multicast stream within the Flash group
"NetGroup.MulticastStream. UnpublishNotify"
dispatched by NetGroup.
However, this event is dispatched only for the multicast stream that is being ingested rather than for any multicast stream within the Flash group.
event that is
event that is

NetConnection class

The server-side NetConnection class lets you create a two-way connection between an Adobe Media Server application instance and an application server, another Adobe Media Server, or another Adobe Media Server application instance on the same server. You can use NetConnection objects to create powerful applications; for example, you can get weather information from an application server or share an application load with other servers that are running Adobe Media Server or application instances.
Availability
Flash Communication Server 1
Last updated 9/20/2013
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.3
Server-Side ActionScript Language Reference
Property summary
Property Description
97
NetConnection.farID Read-only. A String indetifying the RTMFP identify of the Adobe Media Server instance to which
NetConnection.farNonce Read-only. A String unique to this connection. This value appears to another server as its
NetConnection.isConnected Read-only; a boolean value indicating whether a connection has been made.
NetConnection.nearID Read-only. A String indentifier of this Flash Player or Adobe AIR instance for this NetConnection
NetConnection.nearNonce Read-only. A String unique to this connection. This value appears to another server as its
NetConnection.objectEncoding The Action Message Format (AMF) version used to pass binary data between two servers.
NetConnection.rtmfpBindAddress es
NetConnection.rtmfpEndpointNam e
NetConnection.uri Read-only; a string indicating the URI parameter of the NetConnection.connect() method.
this Adobe MediaAdobe Media Server Instance is connected.
NetConnection.nearNonce value.
instance.
NetConnection.farNonce value.
An Array of Strings representing the specific address or addresses that the NetConnection binds locally when it opens its RTMFP protocol stack.
The endpoint name for the local RTMFP protocol stack.
Method summary
Method Description
NetConnection.addHeader() Adds a context header to the Action Message Format (AMF) packet structure.
NetConnection.call() Invokes a command or method on another Adobe Media Server or an application server to which
the application instance is connected.
NetConnection.close() Closes the connection with the server.
NetConnection.connect() Connects to another Adobe Media Server or to a Flash Remoting server such as Adobe ColdFusion.
Event handler summary
Event handler Description
NetConnection.onStatus() Invoked every time the status of the NetConnection object changes.

NetConnection constructor

new NetConnection()
Creates a new instance of the NetConnection class.
Availability
Flash Communication Server 1.
Returns
A NetConnection object.
Example
The following example creates a new instance of the NetConnection class:
Last updated 9/20/2013
Loading...