一 、FMS应该做些什么
2 {
3 import flash.net.NetConnection;
4 import flash.net.NetStream;
5 import flash.display.MovieClip;
6 import flash.net.Responder;
7 import flash.events.MouseEvent;
8 import flash.events.NetStatusEvent;
9 import flash.events.AsyncErrorEvent;
10
11 public class ConnFMS extends MovieClip
12 {
13 private var nc:NetConnection;
14
15 public function ConnFMS()
16 {
17 btnConnFMS.label="连接到FMS";
18 }
19
20 private function onClickHandler(evt:MouseEvent):void
21 {
22 trace("正在连接FMS服务器");
23 nc = new NetConnection();
24 nc.connect("rtmp://localhost/firstFMS");
25 nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
26 }
27
28 private function onNetStatusHandler(evt:NetStatusEvent):void
29 {
30 switch (evt.info.code)
31 {
32 case "NetConnection.Connect.Success":
33 trace("成功连接FMS服务器!");
34 break;
35 case "NetConnection.Connect.Rejected":
36 trace ("访问FMS服务器权限不足,连接被拒绝!");
37 break;
38 case "NetConnection.Connect.InvalidApp":
39 trace("指定的应用程序名称没有找到");
40 break;
41 case "NetConnection.Connect.Failed":
42 trace("连接失败!");
43 break;
44 case "NetConnection.Connect.AppShutDown":
45 trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
46 break;
47 case "NetConnection.Connect.Closed":
48 trace("与FMS的连接中断!");
49 break;
50 }
51 }
52 }
53 }
2 private var netConn:NetConnection;
3 //FMS服务器的地址,使用rtmp协议
4 private var rtmpUrl:String="rtmp://localhost/firstFMS";
2 internal function onInit():void
3 {
4 netConn = new NetConnection();
5 netConn.connect(rtmpUrl);
6 netConn.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
7 netConn.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onAsyncErrorHandler);
8 }
2<mx:Application xmlns:mx="[url]http://www.adobe.com/2006/mxml[/url]" layout="absolute">
3 <mx:.>
4 <![CDATA[
5 import mx.controls.Alert;
6 //Flex与FMS建立连接的对象
7 private var nc:NetConnection;
8 //FMS服务器的地址,使用rtmp协议
9 private var rtmpUrl:String="rtmp://localhost/firstFMS";
10
11 //当Flex应用程序启动的时候就建立与FMS服务器的连接
12 internal function onClick():void
13 {
14 nc = new NetConnection();
15 nc.connect(rtmpUrl);
16 nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
17 nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onAsyncErrorHandler);
18 }
19
20 private function onClickHandler(evt:MouseEvent):void
21 {
22 trace("正在连接FMS服务器");
23 nc = new NetConnection();
24 nc.connect("rtmp://localhost/firstFMS");
25 nc.client=this;
26 nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
27 nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onAsyncErrorHandler);
28 }
29
30 private function onNetStatusHandler(evt:NetStatusEvent):void
31 {
32 switch (evt.info.code)
33 {
34 case "NetConnection.Connect.Success":
35 trace("成功连接FMS服务器!");
36 break;
37 case "NetConnection.Connect.Rejected":
38 trace ("访问FMS服务器权限不足,连接被拒绝!");
39 break;
40 case "NetConnection.Connect.InvalidApp":
41 trace("指定的应用程序名称没有找到");
42 break;
43 case "NetConnection.Connect.Failed":
44 trace("连接失败!");
45 break;
46 case "NetConnection.Connect.AppShutDown":
47 trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
48 break;
49 case "NetConnection.Connect.Closed":
50 trace("与FMS的连接中断!");
51 break;
52 }
53 }
54
55 private function onAsyncErrorHandler(evt:AsyncErrorEvent):void
56 {}
57 ]]>
58 </mx:.>
59 <mx:Button x="135" y="89" label="Button" click="onClick()" fontSize="12" fontWeight="normal"/>
60</mx:Application>
Deploying an unsigned vod service
================================================================
1. Create a new folder in the {FMS-Install-Dir}/applications folder.
2. If you are replacing the default Adobe signed live service, back up
the following files:
* main.far
* Application.xml
* allowedHTMLDomains.txt
* allowedSWFDomains.txt