如何使用FMS3中的实例

FlashMediaServer3.0安装包中
将Samples文件夹(具体路径:Flashmedia3_Int_Strm_ALP/Documentation/Samples)中的所有文件复制到FMS3安装路径下Program Files/Adobe/Flash Media Server 3/applications文件夹中,目的主要是建立服务器端对应的应用程序文件夹和服务端的程序(源文件可以不考,asc文件是必须的)。用户管理和端口号设置和FMS2相同只要修改fms.ini中相应的参数即可。

测试HelloServer实例
客户端代码如下:
package {

 import flash.display.MovieClip;
 import flash.net.NetConnection;
 import flash.events.NetStatusEvent;
 import flash.events.MouseEvent;
 
 public class HelloServer extends MovieClip {
       
   private var nc:NetConnection;
  
   /*
    *  Constructor.
    */
   public function HelloServer() {
      // register listeners for mouse clicks on the two buttons
   connectBtn.addEventListener(MouseEvent.CLICK, connectHandler);
   closeBtn.addEventListener(MouseEvent.CLICK, closeHandler);
   }
  
 
  /*
   *  Connect to the server.
   */
  public function connectHandler(event:MouseEvent):void {
      trace("Okay, let's connect now");
    nc = new NetConnection();
   nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            nc.connect("rtmp://localhost/HelloServer");
  }
 
 
  /*
   *  Disconnect from the server.
   */
  public function closeHandler(event:MouseEvent):void {
      trace("Now we're disconnecting");
   nc.close();
  }
 
 
  /*
   *  Handle events relating to the server connection.
   */
  public function netStatusHandler(event:NetStatusEvent):void {
            trace("connected is: " + nc.connected);
   trace("event.info.level: " + event.info.level);
   trace("event.info.code: " + event.info.code);
   
   switch (event.info.code)
            {
                case "NetConnection.Connect.Success":
                 trace("Congratulations! you're connected" + "/n");
                 break;
                case "NetConnection.Connect.Rejected":
                 trace ("Oops! the connection was rejected" + "/n");
                 break;
    case "NetConnection.Connect.Closed":
     trace("Thanks! the connection has been closed" + "/n");
     break;
        }
     }
 
 
   }
}

输出结果如下:
连接FMS服务器时

Okay, let's connect now
connected is: true
event.info.level: status
event.info.code: NetConnection.Connect.Success
Congratulations! you're connected

断开服务器时

Now we're disconnecting
connected is: false
event.info.level: status
event.info.code: NetConnection.Connect.Closed
Thanks! the connection has been closed


fms3_8

fms3_8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值