`
hgfghe3
  • 浏览: 50469 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

flash与后台数据交换方法整理2-Flash Remting篇

阅读更多

二、Flash Remoting
  Flash Remoting这种数据接口是四个之中效率最高的!
  其优点:
    1.支持数据类型比较多(Converting from application server data types to ActionScript);
    2.传递数据量比较大;
    3.运行效率是现有几个当中最高的;
    4.对各种后台的支持也比较好;
    5.其还有调试模块(NetConnection Debugger)
   
  其缺点:
    1.需要flash端装Flash Remoting MX Components(这个是免费提供的);
    2.需要后台服务端装相应版本的Flash Remoting模块才可以使用,MM提供的模块有j2ee和.net两个版本是要收费的,好在网上还有两个开源的(OpenAMF,AMFPHP);
    3.好像Remoting对虚拟主机的支持不太好(可以去google搜索一下,有没有解决方法).
================================================================
  Flash端代码说明:(我这里用as1.0版本为例,其他版本到MM站查找)
================================================================
  //加载Remoting Component代码,这个是必须的;
  #include "NetServices.as"
  //加载Remoting 调试模块代码,这个是可选择的,用NetConnection Debugger查看调试信息;
  #include "NetDebug.as"
  if (inited == null){ 
    inited = true;
    //设置默认网关;
    NetServices.setDefaultGatewayUrl("
:8500/flashservices/gateway
");
    //建立网关连接;
    gateway_conn = NetServices.createGatewayConnection();
    //获取一个服务;
    myService = gateway_conn.getService("myservice", this);
  }
 
  //定义调用方法的函数;
  function getString(name){
    //调用Remoting的getString方法;
    myService.getString(name);
  }
  //定义返回结果的函数;
  function getString_Result(result){
    //result就为返回的结果;
    trace(result);
  }
  //定义返回状态的函数,此为可选的;
  function getString_Status(error){
    trace("getString_Status");
    trace(error.code);
    trace(error.description);
    trace(error.details);
  }
 
  //调用函数;
  getString("kinglong");
 
================================================================
  服务端方法定义(我这里以Coldfusion Component为例,其他版本请参考相应的资料)
================================================================
另附上Flash Remoting的在线帮助文件(Flash Remoting LiveDocs),MM网站上的Remoting相关的资料.
    1.LoadVars(XML)
    2.Flash Remoting
    3.Webservice
    4.XMLSocket
本文转自:http://www.5uflash.com/flashjiaocheng/Flashyuweb/2081.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics