C#程序与Flash的接口
来源:互联网 发布:jquery json解析{} 编辑:程序博客网 时间:2024/05/16 01:18
参照sourceforge的开源项目,数据传输采用WDDX方法把对象及其属性串行化,接收端则解串行化解析出相应的数据。
//****************************************************************************// ______// .-" "-.// / AOL /// | |// |, .-. .-. ,|// | )(__/ /__)( |// |/ // /|// (@_ (_ ^^ _)// _ ) /_______/__|IIIIII|__/__________________________// (_)@8@8{}<________|-/IIIIII/-|___________________________>// )_/ / /// (@ `--------` AOL FLASH STUDIO.//****************************************************************************// @FileName SharpFlash.as// @Package sharpflash// @Description C#程序与flash交互的接口,采用Singleton模式,只允许一个接口// @Author aol// @Email jeremy1982@21cn.com// @Create 2004.10.10// @LastChange 2004.10.11// @History//****************************************************************************class sharpflash.SharpFlash{ private static var _instance:SharpFlash; public static function get instance():SharpFlash { //trace(_instance); if (_instance == null) { _instance = new SharpFlash(); } return _instance; } /////////////////////////////////////////////////////// private var _data:String; private var watch:Function; private var wddx:Wddx; private var callBackList:Array; //构造函数 private function SharpFlash() { wddx = new Wddx(); this.watch("data",onData); } //属性data,由C#来赋值,flash监视其值的变化 public function get data():String { return _data; } public function set data(value:String):Void { _data = value; } //data变化处理方法 function onData(prop:String, oldVal:String, newVal:String) { // _root.result.text = newVal; var xml:XML = new XML(); xml.parseXML(newVal); var response_xml:XMLNode = xml.firstChild.firstChild; //回调函数ID var tmp:XMLNode = response_xml.childNodes[0].firstChild; // callback 函数在这个结点里面有一个或者两个参数 // 通过解析从C#端发送的包的arg结点可以得出参数的数目 var argCount:Number = response_xml.childNodes[1].childNodes.length; // _root.result.text = argCount; switch (argCount) { case 1: var arg1_wddx_xml:XML = new XML(); arg1_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[0].firstChild); var funcArgs = new Array(1); funcArgs[0] = wddx.deserialize(arg1_wddx_xml); // 执行 callBackList[tmp].callback.apply(callBackList[tmp].scope, funcArgs); // debug 代码: // _root.result.text = "1 Arg Result: [0] = " + funcArgs[0]; break; case 2: var arg1_wddx_xml:XML = new XML(); arg1_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[0].firstChild); var arg2_wddx_xml:XML = new XML(); arg2_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[1].firstChild); var funcArgs:Array = new Array(2); funcArgs[0] = wddx.deserialize(arg1_wddx_xml); funcArgs[1] = wddx.deserialize(arg2_wddx_xml); // 执行 callBackList[tmp].callback.apply(callBackList[tmp].scope, funcArgs); // debug 代码: //_root.result.text = "2 Arg Result: [0] = " + funcArgs[0] + "/n[1] = " + funcArgs[1]; break; default: break; } }};
一个小示例,由C#得出当前程序所在路径。
- C#程序与Flash的接口
- C#与Flash通信的服务端程序
- C#与Flash通信的客户端程序
- C#与 Flash 程序开发
- C#与 Flash 程序开发
- C#与 Flash 程序开发
- C#与 Flash 程序开发
- c#与FLASH的交互
- Nor Flash的CFI与JEDEC接口
- Flash与C#结合,打造完美WinForm程序
- C#与Flash交互
- C#与Flash交互
- C#与Flash交互
- C#与Flash交互
- c# 与flash
- C# 与Flash 通信
- Flash与C#通信
- C#与Flash交互
- 如何声明 findwindow 函数。
- 存储图片(C#+Winform+SQL Server)
- UART (Universal Asynchronous Receiver/Transmitter)
- Makefile写法
- Testing—《软件测试》读书笔记(一)
- C#程序与Flash的接口
- 世界500强和中国500强企业名单(2004年度前100名)
- 简介
- vi的使用
- 关于xml的模糊查询问题
- ASP控制图片显示的大小(等比例缩放)
- deleted 和 inserted 是逻辑(概念)表。
- [转贴]Lotus Domino/Notes与Microsoft Exchange的比较分析
- 安装文件如何打包SQL数据库?