
120
FLASH
MEDIA
SERVER
4.5
CONFIGURATION
AND
ADMINISTRATION
Using the Administration API
Last updated 11/28/2012
This example uses the NetConnection class to make a single request to the Flash Media Server. If you want to create a
persistent connection that updates automatically (like the Administration Console), you can use the NetStream class
to create a streaming connection over the NetConnection.
Create your first application in Flex
The following application built in Flex uses the HTTPService class to call the Flash Media Server administration API.
It calls the
getAppStats
method and prints the results to the TextArea control.
Before you compile and run this example, you must add your admin username and password to the request
parameters.
When you run the example, enter an application name in the TextInput control and click the Get App Stats button.
Default applications include “live” and “vod”, but you can use the name of any application that you created on the
server.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<s:HTTPService id="myService"
url="http://localhost:1111/admin/getAppStats"
method="GET"
resultFormat="e4x"
result="myServiceResultHandler()">
<s:request xmlns="">
<!-- Replace these with your admin username and password. -->
<auser>your_admin_username</auser>
<apswd>your_admin_password</apswd>
</s:request>
</s:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
private function myServiceResultHandler():void {
outputBox.text = myService.lastResult.toString();
}
private function doButtonClick():void {