文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>flash与后台的交互

flash与后台的交互

时间:2011-01-17  来源:A好心情S

 

二、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搜索一下,有没有解决方法).



//=====================================================;
//服务端方法定义(我这里以Coldfusion Component为例,其他版本请参考相应的资料)
//=====================================================;
<!---文件名为myservice.cfc--->
<cfcomponent displayname="我的服务">
<!---定义了getString方法,需将access设为remote,否则Flash remoting无法调用此方法--->
<cffunction name="getString" access="remote" returntype="string">
<cfargument name="name" type="string" required="true">
<cfset myResult = arguments.name & ",欢迎你!">
<cfreturn myResult>
</cffunction>
</cfcomponent>

另附上Flash Remoting的在线帮助文件(Flash Remoting LiveDocs),MM网站上的Remoting相关的资料.

//=====================================================;
//Flash端代码说明:(我这里用as1.0版本为例,其他版本到MM站查找)
//=====================================================;
//加载Remoting Component代码,这个是必须的;
#include "NetServices.as"
//加载Remoting 调试模块代码,这个是可选择的,用NetConnection Debugger查看调试信息;
#include "NetDebug.as"
if (inited == null){
inited = true;
//设置默认网关;
NetServices.setDefaultGatewayUrl("http://localhost: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");

 

 

 

相关阅读 更多 +
排行榜 更多 +
瓢虫少女

瓢虫少女

飞行射击 下载
潜艇鱼雷

潜艇鱼雷

飞行射击 下载
网络掠夺者

网络掠夺者

飞行射击 下载