A simple application example
This section contains the code for a simple Flash application that calls the
method. You can copy and paste this code into Flash to see how a simple call works.
In Flash, create an application with the following elements:
An input field named Application Name with a border
A button that calls the
follows)
A multiline, dynamic text field called outputBox that has a border
A scroll component next to the text field
This simple interface lets you test the Server Management ActionScript API.
Next, in the Actions panel, enter the sample ActionScript code that follows. Be sure to replace
and
admin_name
admin_pass
The continuation character (
character should not appear in code.
/** Establishes the connection to Flash Media Server **/
nc = new NetConnection();
nc.connect("rtmp://localhost:1111/admin","admin_name","admin_pass");
/** Makes the API call, for example, "GetAppStats" **/
function doGetAppStats() {
function onGetAppStats()
{
this.onResult = function(info)
{
if (info.code != "NetConnection.Call.Success")
outputBox.text = "Call failed: " + info.description;
else {
outputBox.text = "Info for "+appName.text+ " returned:" + ¬
newline;
printObj(info, outputBox);
}
}
}
nc.call("getAppStats", new onGetAppStats(), appName.text);
}
// This function proceeds through an object, printing all values to the
// destination, including recursively printing objects within objects.
// The tabLevel parameter is used for cosmetic purposes.
function printObj(obj, destination, tabLevel)
method (shown in the code sample that
doGetAppStats()
with your valid administrator name and password.
) indicates that the code continues to the next line; this
¬
getAppStats
A simple application example
7
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-SERVER MANAGEMENT ACTIONSCRIPT LANGUAGE and is the answer not in the manual?