ASP.NET与Flex的交互实例入门教程

今天决定写一篇ASP.NET与Flex交互的案例!为了这个交互俺查了好多资料好多网页看的俺眼睛开花,脑开窍!最后发飙了!终于成功了!嘿!老虎不发威还真MD以为俺是hello cat!所以今天想写出一份详细教程供大家参考!减少类似像我这类初学者走弯路!俗话说:授人玫瑰,手留鮽香!!好了废话不多说!Move



如果大家要上传到服务器建议大家使用VS2005
如果只是内部测试的话大家可以选择这个速成版
        


1.Visual Web Developer 2005 Express Edition
     下载地址:ftp://www.msuniversity.edu.cn/Express/VNS_CHS.iso

2.Flex Bulider 3
       下载地址:http://trials.adobe.com/Applications/Flex/FlexBuilder/3/FB3_WWEJ_Plugin.exe
       注册码:1377-4868-2899-3328-2083-1968

3. FluorineFx v1.0.0.13.exe
     下载地址: http://www.fluorinefx.com/download/fluorinefx/1.0.0.13/fluorinefx.exe

4.  Visual studio 2005
     下载地址:http://www.pojiezhan.com/d/download.php?n=1&server=url_1&id=2228::1194414715


特别说明:安装顺序1-2-3可别弄混了!如果是VS2008或VS2005的话直接安装完就可以建立以FluorineFx为中间件的交互了!可以跳到步奏5 !

但是如果是本案例的ASP.NET速成版的话就要手动配置:

1.启动ASP.NET速成版
2.新建网站
 



3.右键这个选中-添加引用
 




4.找到FluorineFx的安装文件夹的NET目录我这里是D:"Program Files"FluorineFx"Bin"net"2.0把这几个文件给添加上


5.然后继续右键选中F:"kaka":添加ASP.NET文件夹的App_Code
右键选中App_Code添加新项---新建一个HelloWorld类!

运行页面得到地址和端口:http://localhost:2943/kaka (这个后面要用到!重要!)

在HelloWorld类中添加如下代码:

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FluorineFx;
namespace tutorials.remoting
{
    [RemotingService()]
    
public class HelloWorld
    {
        
public string sayHello(string userName)
        {
            
return "您好," + userName + "这是来自Fluorine Flash remoting的问候";
        }
    }
}



然后右键选中Console.aspx文件---设置为起始页




运行可以看到

OK!到此ASP.NET这边的工作告一段落!

接下来咱玩一下Flex

1.新建一个Flex project设置如下
 



Flex项目文件保存位置不要错了是asp.net项目文件夹之下本案例是kaka文件夹之下的FlexWeb目录!
next吧
 



说明:WebRoot:是asp.net项目的所在目录
      RootUrl:是刚才前面所提到的端口和地址
      Context root:就是和RootUrl目录的子文件夹(本案例为:kaka则设为kaka!如为flex3则为flex3)
      然后一下吧!正确设置的话上面会提示:

The web root folder and root URL are valid
      Next-Finish吧!
2.接下来就是MXML代码咯如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#72E4CD, #336A90]">
<mx:RemoteObject id="service" destination="fluorine"
  source
="tutorials.remoting.HelloWorld" showBusyCursor="true" />
<mx:TextInput id="txtName"/>
<mx:Button label="Say Hello" click="service.sayHello(txtName.text)"/>
<mx:Label text="{service.sayHello.lastResult}" fontSize="18"/>
</mx:Application>



3.接下来就是把

3.运行Flex程序看看墨子效果吧!

原文地址:https://www.cnblogs.com/yeagen/p/1394409.html