C#的类声明:using System;using System.Collections.Generic;using System.Text;namespace TestFlash{public class TestFlash{public string Test(){return "test...";}}}FLASH调用方法:import mx.remoting.*;import mx.rpc.*;function InvoteGateway(){var GatewayURL:String = "";//FLASH网关地址var ClassURL:String = "TestFlash.TestFlash";// 命名空间和类名var FunctionName:String = "Test";// 方法名var newService:Service = new Service(GatewayURL, null, ClassURL, null, null);var pc:pendingCall = eval("newService."+FunctionName)(obj);pc.responder = new RelayResponder(this, "onRemotingResult", "onRemotingFault");}function onRemotingResult(re:ResultEvent){txtResult.text = re.result;// 值则为test...}function onRemotingFault(fault:FaultEvent){trace(fault.fault.faultstring);}run.addEventListener("click",InvoteGateway());
运行环境配置:
1. 配置.NET运行环境:
安装Dotnet Framework 2.0版本
2. 配置Flashremoting运行环境:
最好首先安装Flash8,然后安装flashremoting-net-win-en2.exe,最后安装flashremoting_components_flash8.msi.
这样就OK了,运行一下FLASH你就可以调用.NET的方法啦...