使用Fluorine实现Flash与.NET之间的Remoting通信
简单实例代码,配置环境省略
//AS3代码
package
{
import flash.net.NetConnection;
import flash.net.Responder;
import flash.display.*;
public class 测试代码用 extends Sprite
{
function 测试代码用():void
{
trace("Begin");
//这个用来接受结果
var rp:Responder = new Responder(OnResult,OnError);
//创建对象
var nc:NetConnection = new NetConnection();
//连接Remoting网关
nc.connect("http://localhost:5666/WebSite3/Gateway.aspx");
//调用CALL方法,“”号内依次为【命名空间】.【类名】.【方法】,rp为接收结果的对象
nc.call("FirstRemoting.HelloWorld.HW",rp);
}
private function OnResult(result:String):void
{
trace(result);
trace("OK");
}
private function OnError(result:Object):void
{
trace("Wrong");
}
}
}
//.NET端代码,App_Code下HelloWorld类
using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
//这个引用很重要
using FluorineFx;
//命名空间
namespace FirstRemoting
{
//这句很重要,不能少
[RemotingService("Fluorine sample service")]
public class HelloWorld
{
public string HW()
{
string text = "HelloWorld";
return text;
}
}
}
posted on 2008-12-08 14:28 jinglikeblue 阅读(82) 评论(0) 收藏 举报