1、在FMS安装applications,新建一个文件夹,firstFMS
2、flex builder 新建一个flex项目,名为firstFMS,在firstFMS.mxml里面写入以下代码:
[color=red] 注意:若不能连接,重新下一个FMS安装,建议:FMS3.5[/color]
2、flex builder 新建一个flex项目,名为firstFMS,在firstFMS.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="flex连接fms">
<mx:Button x="10" y="121" label="测试" 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>
[color=red] 注意:若不能连接,重新下一个FMS安装,建议:FMS3.5[/color]