加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

FMS + Flex HelloWorld

发布时间:2020-12-15 04:52:30 所属栏目:百科 来源:网络整理
导读:1. 安装 Flash Media Development Server 并启动服务 2. 安装Flash Builder 3. 用Flash Builder 文件 - 新建 - Flex手机项目 - HelloWorld 4. 修改HelloWorldView.mxml代码如下: ?xml version="1.0" encoding="utf-8"? s:View xmlns:fx="http://ns.adobe.co

1. 安装 Flash Media Development Server 并启动服务

2. 安装Flash Builder

3. 用Flash Builder 文件 -> 新建 -> Flex手机项目 -> HelloWorld

4. 修改HelloWorldView.mxml代码如下:

<?xml version="1.0" encoding="utf-8"?>
< s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
? xmlns:s="library://ns.adobe.com/flex/spark"
? title="主页视图"
? creationComplete="initView()">

<fx:Script>
? <![CDATA[
?? import flash.events.MediaEvent;
?? import flash.net.NetConnection;
?? import flash.net.Responder;
??
?? import mx.rpc.events.ResultEvent;
??
?? private var nc:NetConnection;
?? private var myResponder:Responder= new Responder(onReply);
??
?? private function initView():void{
??? tt.text="display responder result...";
??? conBt.label="connect";
?? }
??
?? protected function conBt_clickHandler(event:MouseEvent):void
?? {
??? // TODO Auto-generated method stub
??? if(conBt.label == "connect"){
???? trace("Connect...");
???? nc = new NetConnection();
???? nc.connect("rtmp://localhost/HelloWorld");
???? nc.call("serverHelloMsg",myResponder,"World");
???? conBt.label = "disconnect";
??? }else {????
???? trace("Disconnecting...");
???? nc.close();????
???? conBt.label = "connect";????
???? tt.text = "display responder result...";????
??? }
???????
?? }
??
?? private? function onReply(result:Object):void{
??? trace("onReply received value: "+ result);
??? tt.text=String(result);
?? }
? ]]>
</fx:Script>

<fx:Declarations>
? <!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>?

<s:VGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">??????
?
? <s:Button id="conBt"? click="conBt_clickHandler(event)" />
? <s:Label id="tt"" />
?
</s:VGroup>

< /s:View>

5. 编写FMS服务器脚本文件HelloWorld.asc,UTF-8编码格式,代码如下:

application.onConnect=function(client){
client.serverHelloMsg=function(helloStr){
? return "Hello," + helloStr + "!";
}
application.acceptConnection(client);
}

6.FMS安装目录C:Program FilesAdobeFlash Media Server 4.5applications创建文件夹HelloWorld,并将HelloWorld.asc拷贝到新建HelloWorld目录内

7. 配置Flash Builder HelloWorld工程 运行方式 -> 运行配置 -> 启动方法:在桌面上(Motorola Droid Pro)

8.运行Flash Builder HelloWord工程,测试通过。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读