`
arm25arm
  • 浏览: 17982 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

FMS helloworld

 
阅读更多

FMS helloworld
2011年05月17日
  Start Flash and select Create New > Flash File (ActionScript 3.0). In the Document Class field, enter HelloWorld. If you see an ActionScript Class Warning message about a missing definition-click OK. You will add the class file in the next section. Choose Windows > Components. Click User Interface and double-click Button to add it to the Stage. On the Properties tab, enter the instance name connectBtn.  Add a Label component above the button, and give it the instance name textLbl. Save the file as HelloWorld.fla. You can save the client files to any location. This script provides two button actions, either connecting to or disconnecting from the server. When connecting, the script calls the server with a string ("World"), which triggers a response that displays the returned string ("Hello, World!"). Choose File > New > ActionScript File. Check that the Target box has HelloWorld.fla.  Declare the package and import the required Flash classes: package { import flash.display.MovieClip; import flash.net.Responder; import flash.net.NetConnection; import flash.events.NetStatusEvent; import flash.events.MouseEvent; public class HelloWorld extends MovieClip { } }
  Inside the HelloWorld class declaration, declare variables for the connection and the server responder: private var nc:NetConnection; private var myResponder:Responder = new Responder(onReply);
  Define the class constructor. Set the label and button display values, and add an event listener to the button: public function HelloWorld() { textLbl.text = ""; connectBtn.label = "Connect"; connectBtn.addEventListener(MouseEvent.CLICK, connectHandler); }
  Define the event listener actions, which depend on the button's current label: public function connectHandler(event:MouseEvent):void { if (connectBtn.label == "Connect") { trace("Connecting..."); nc = new NetConnection(); // Connect to the server. nc.connect("rtmp://localhost/HelloWorld"); // Call the server's client function serverHelloMsg, in HelloWorld.asc. nc.call("serverHelloMsg", myResponder, "World"); connectBtn.label = "Disconnect"; } else { trace("Disconnecting..."); // Close the connection. nc.close(); connectBtn.label = "Connect"; textLbl.text = ""; } }
  Define the responder function, which sets the label's display value: private function onReply(result:Object):void { trace("onReply received value: " + result); textLbl.text = String(result); }
  Save the file as HelloWorld.as to the same folder as the HelloWorld.fla file. Choose File > New > ActionScript Communications File.  Define the server-side function and the connection logic: application.onConnect = function( client ) { client.serverHelloMsg = function( helloStr ) { return "Hello, " + helloStr + "!"; } application.acceptConnection( client ); }
  Save the file as HelloWorld.asc in the rootinstall/applications/HelloWorld folder. (Create the "HelloWorld" folder when you save the file.) Verify that the server is running. Select the HelloWorld.fla file tab. Choose Control > Test Movie. Click the Connect button. "Hello, World!" is displayed, and the button label changes to Disconnect. Click the Disconnect button. The output of the trace() statements is displayed in the Flash Output window.
分享到:
评论

相关推荐

    FMS 4.5 + Flex mobile 之 Hello World 工程源代码

    FMS 4.5 + Flex mobile 之 Hello World 工程源代码,包括FMS 服务器端asc脚本和Flex Mobile客户端工程源代码,供入门参考。

    FMS聊天室下载FMS

    FMS聊天室FMS聊天室FMS聊天室FMS聊天室FMS聊天室

    FMS 4.5 注册码

    FMS4.5 注册码 FMS4.5 测试可用

    FMS3翻译docx版本

    1.3 hello world 应用程序 1.3.1前言 注释:下面的部分应用于Flash Media Interactive Server 和Flash Media Development Server者两个版本的服务。 这个例子使用flash CS3来展示...范例文件在HelloWorld文件夹下。

    fms + flex 开发

    FMS的最新版本已经到FMS 3了 ,本入门教程使用Flash Media Server 2 演示,但你可以很容易的升到 3,因为FMS 到 FMS3 的更新几乎没有什么改动 ,还有本教程客户端使用as1演示如果你需要用AS3的话,语法会有些变化,...

    FMS 5.0 注册码

    FMS FMS5 FlashMediaServer5注册码

    FMS 模拟飞行软件

    FMS虽然没有对模型参数的设定操作,但FMS把每架模型的参数写在一个扩展名为。par的文本文件内,我们可以很轻易地对其进行编辑、修改,使模型性能更适合于自己使用。 FMS在操纵方式上也很灵活,可以使用键盘、游戏...

    FMS视频聊天程序

    fms,flash,视频聊天fms,flash,视频聊天fms,flash,视频聊天

    实战训练25 FMS状态机_fms_fpga_

    FMS状态机,使用状态机来实现的verilog代码,写程序必备的学习

    FMS3中文翻译

    FMS3中文翻译.doc

    FMS视频会议源代码

    fms视频会议源代码,Flash + FMS

    FMS服务器端加密

    FMS服务器端app加密

    asp+fms聊天室

    asp+fms语音聊天室asp+fms语音聊天室

    FMS4.0序列號

    FMS4.0注册码 FlashMediaServer5序列号

    网博Fms在线直播系统

    网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统网博Fms在线直播系统

    FMS BUG解说图.rar

    FMS BUG解说图.rar

    fms.rar_flex_flex and fms_fms_fms rtmp_fms flex

    利用flex和FMS建立聊天室,fms为源码

    FMS中文帮助文档

    FMS中文帮助文档,很有用的。特别适合flex和fms交互方面的需求

    流媒体服务器FMS3.5

    流媒体服务器FMS3.5 sn:1373-5465-5574-9110-6240-7230

    FMS2.0软件

    FMS开发Flash Media Server 入门教程 我把我以前的那些FMS学习笔记整理了一下,做了下修改,成了一页的FMS教程,方便想学FMS的新手来看,如果还有错误或者看不懂的地方欢迎留言,或email偶,偶会进行更改 什么是...

Global site tag (gtag.js) - Google Analytics