`
ljl_xyf
  • 浏览: 618148 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flex连接fms

阅读更多

fms.mxml

<?xml version="1.0" encoding="utf-8"?>
<!--http://www.blueidea.com/tech/multimedia/2007/4990.asp--> <!--ffmpeg-->
<!--http://www.cnblogs.com/beniao/archive/2009/02/27/1392115.html-->
<!--http://livedocs.adobe.com/flashmediaserver/3.0/docs/help.html-->
<!--http://www.adobe.com/cfusion/tdrc/index.cfm?product=flashmediaserver&loc=en_us-->
<!--http://hi.baidu.com/webok/blog/item/a1f5bbd3ee23d13c960a164b.html-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml " layout="absolute" fontSize="14" fontFamily="arial">
    <mx:Script>
       <![CDATA[
            import mx.controls.Alert;
            //Flex与FMS建立连接的对象
            private var nc:NetConnection;
            //FMS服务器的地址,使用rtmp协议
            private var rtmpUrl:String="rtmp://localhost/firstFMS";
            //当Flex应用程序启动的时候就建立与FMS服务器的连接
           internal function goconnect():void
           {
               nc = new NetConnection();
               nc.connect(rtmpUrl);
               nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
               nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,onAsyncErrorHandler);
            }
      
           private function onNetStatusHandler(evt:NetStatusEvent):void
            {
                switch (evt.info.code)
               {
                   case "NetConnection.Connect.Success":
                       Alert.show("成功连接FMS服务器!");
                       break;
                  case "NetConnection.Connect.Rejected":
                       Alert.show("访问FMS服务器权限不足,连接被拒绝!");
                       break;
                   case "NetConnection.Connect.InvalidApp":
                        Alert.show("指定的应用程序名称没有找到");
                       break;
                    case "NetConnection.Connect.Failed":
                       Alert.show("连接失败!");
                        break;
                   case "NetConnection.Connect.AppShutDown":
                       Alert.show("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
                       break;
                   case "NetConnection.Connect.Closed":
                        Alert.show("与FMS的连接中断!");
                        break;
               }
           }
          
           private function onAsyncErrorHandler(evt:AsyncErrorEvent):void
          {
         
          }
   ]]>
   </mx:Script>
    <mx:Panel horizontalCenter="0" verticalCenter="0" width="250" height="200" layout="absolute" title="http://www.my400800.cn ">
        <mx:Button x="10" y="121" label="400电话 " click="goconnect()" fontSize="12" fontWeight="normal"/>
   <mx:Text id="text1" text="hello the worldhello th
   e worldhello the worldhello the worldhello the worl
   dhello the worldhello the worldhello the worldhello
   the worldhello the worldhello the worldhello the worldhe
   llo the worldhello the worldhello the worldhello the world
   hello the worldhello the worldhello the worldhello the w
   orldhello the worldhello the worldhello the worldhello the
    worldhello the worldhello the world!" x="10" y="10" width="210" height="103">
  
   </mx:Text>
    </mx:Panel>
</mx:Application>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics